Task state values

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • Task state values

      The OS_TASK struct has a variable "stat" with the type OS_STAT.
      I assume it indicates the state of the current task. As per documentation, - the state can be ready, waiting, reason for suspension, etc.
      Can you please tell me what values of "stat" correspond to which task states.
      I did not find it anyhwere in the code or documentation.
    • Hello ndongre,

      May I ask for the reason why you want to check a tasks state?

      The values of the task states are not described in the manual as we prohibit the use of embOS internal variables.

      Please note that embOS internal variables and structures as well as their meaning can change among different embOS versions and in new releases.

      In embOS V506 following defines are used for OS_STAT:

      C Source Code

      1. /*********************************************************************
      2. *
      3. * Define Task states
      4. *
      5. **********************************************************************
      6. *
      7. * Notes:
      8. * The lower 3 bits are used for bits which may be combined with any
      9. * state. The upper 5 bits are used to indicate the state.
      10. * Bits 0..1 are used as 2-bit Suspend counter (allowing values from 0..3),
      11. * bit 2 is used to indicate a timeout.
      12. *
      13. * Bit 0..1: Suspend counter
      14. * Bit 2 : Timeout
      15. * Bit 3..7: Task state
      16. */
      17. #define TS_MASK_SUSPEND_CNT (0x03u) // Mask for Suspend Counter
      18. #define TS_MASK_TIMEOUT (0x04u) // Mask for timeout
      19. #define TS_MASK_STATE (0xF8u) // Mask for task states
      20. //
      21. // Task states
      22. //
      23. #define OS_TS_READY (0u << 3u) // Ready
      24. #define OS_TS_WAIT_EVENT (1u << 3u) // Waiting for Task event
      25. #define OS_TS_WAIT_MUTEX (2u << 3u) // Waiting for Mutex
      26. #define OS_TS_WAIT_ANY (3u << 3u) // Waiting for any reason (currently used in OS_COM_SendString() only)
      27. #define OS_TS_WAIT_SEMAPHORE (4u << 3u) // Waiting for Semaphore not zero
      28. #define OS_TS_WAIT_MEMF (5u << 3u) // Waiting for Memory pool
      29. #define OS_TS_WAIT_QNE (6u << 3u) // Waiting for Queue not empty
      30. #define OS_TS_WAIT_MBNF (7u << 3u) // Waiting for Mailbox not full
      31. #define OS_TS_WAIT_MBNE (8u << 3u) // Waiting for Mailbox not empty
      32. #define OS_TS_WAIT_EVENTOBJ (9u << 3u) // Waiting for Event object
      33. #define OS_TS_WAIT_QNF (10u << 3u) // Waiting for Queue not full
      Display All
      Best regards,
      Michael Mleczko