#ifndef CMA_TCB_DEFS
#define CMA_TCB_DEFS
# if !_CMA_THREAD_SYNC_IO_
# include <cma_thread_io.h>
# endif
#include <cma.h>
#include <cma_debug_client.h>
#include <cma_attr.h>
#include <cma_defs.h>
#include <cma_handle.h>
#include <cma_queue.h>
#if _CMA_OS_ == _CMA__UNIX
# if defined(SNI_DCOSX)
# include <sys/ucontext.h>
# endif
# include <signal.h>
#endif
#include <cma_sched.h>
#if _CMA_PLATFORM_ == _CMA__IBMR2_UNIX
# define cma__c_ibmr2_ctx_stack_size 2048
# define cma__c_ibmr2_ctx_stack_top (cma__c_ibmr2_ctx_stack_size - 1)
#endif
#ifndef __STDC__
# if _CMA_HARDWARE_ != _CMA__HPPA
struct CMA__T_SEMAPHORE;
# endif
struct CMA__T_INT_CV;
struct CMA__T_INT_MUTEX;
struct CMA__T_INT_TCB;
#endif
typedef cma_t_address *cma__t_context_list;
typedef struct CMA__T_TCB_PAD {
cma_t_integer pad1;
cma_t_integer pad2;
cma_t_integer pad3;
} cma__t_tcb_pad;
#if (_CMA_OS_ == _CMA__UNIX) && !_CMA_THREAD_SYNC_IO_
typedef struct CMA__T_TCB_SELECT {
cma__t_queue queue;
#if (_CMA_UNIX_TYPE != _CMA__SVR4)
cma__t_file_mask *rfds;
cma__t_file_mask *wfds;
cma__t_file_mask *efds;
#else
cma__t_poll_info poll_info;
#endif
cma_t_integer nfound;
} cma__t_tcb_select;
#endif
typedef struct CMA__T_TCB_TIME {
cma__t_queue queue;
cma_t_integer mode;
struct CMA__T_SEMAPHORE *semaphore;
cma_t_date_time wakeup_time;
cma_t_integer quanta_remaining;
} cma__t_tcb_time;
typedef enum CMA__T_DEBEVT {
cma__c_debevt_activating = 1,
cma__c_debevt_running = 2,
cma__c_debevt_preempting = 3,
cma__c_debevt_blocking = 4,
cma__c_debevt_terminating = 5,
cma__c_debevt_term_alert = 6,
cma__c_debevt_term_exc = 7,
cma__c_debevt_exc_handled = 8
} cma__t_debevt;
#define cma__c_debevt__first ((cma_t_integer)cma__c_debevt_activating)
#define cma__c_debevt__last ((cma_t_integer)cma__c_debevt_exc_handled)
#define cma__c_debevt__dim (cma__c_debevt__last + 1)
typedef enum CMA__T_SUBSTATE {
cma__c_substa_normal = 0,
cma__c_substa_mutex = 1,
cma__c_substa_cv = 2,
cma__c_substa_timed_cv = 3,
cma__c_substa_term_alt = 4,
cma__c_substa_term_exc = 5,
cma__c_substa_delay =6,
cma__c_substa_not_yet_run = 7
} cma__t_substate;
#define cma__c_substa__first ((cma_t_integer)cma__c_substa_normal)
#define cma__c_substa__last ((cma_t_integer)cma__c_substa_not_yet_run)
#define cma__c_substa__dim (cma__c_substa__last + 1)
typedef struct CMA__T_TCB_DEBUG {
cma_t_boolean on_hold;
cma_t_boolean activated;
cma_t_boolean did_preempt;
cma_t_address start_pc;
cma_t_address object_addr;
cma__t_substate substate;
cma_t_boolean notify_debugger;
cma_t_address SPARE2;
cma_t_address SPARE3;
struct CMA__T_INT_TCB
*preempted_tcb;
cma_t_boolean flags[cma__c_debevt__dim];
} cma__t_tcb_debug;
typedef struct CMA__T_TCB_SCHED {
cma_t_integer adj_time;
cma_t_integer tot_time;
cma_t_integer time_stamp;
cma_t_integer cpu_time;
cma_t_integer cpu_ticks;
cma_t_integer q_num;
cma_t_priority priority;
cma_t_sched_policy policy;
cma_t_boolean rtb;
cma_t_boolean spp;
cma_t_boolean fixed_prio;
cma__t_sched_class class;
struct CMA__T_VP *processor;
} cma__t_tcb_sched;
typedef struct CMA__T_INT_ALERT {
cma_t_boolean pending : 1;
cma_t_boolean g_enable : 1;
cma_t_boolean a_enable : 1;
cma_t_integer spare : 29;
cma_t_natural count;
} cma__t_int_alert;
typedef enum CMA__T_STATE {
cma__c_state_running = 0,
cma__c_state_ready = 1,
cma__c_state_blocked = 2,
cma__c_state_terminated = 3
} cma__t_state;
#define cma__c_state__first ((cma_t_integer)cma__c_state_running)
#define cma__c_state__last ((cma_t_integer)cma__c_state_terminated)
#define cma__c_state__dim (cma__c_state__last + 1)
typedef enum CMA__T_THKIND {
cma__c_thkind_initial = 0,
cma__c_thkind_normal = 1,
cma__c_thkind_null = 2
} cma__t_thkind;
#define cma__c_thkind__first ((cma_t_integer)cma__c_thkind_initial)
#define cma__c_thkind__last ((cma_t_integer)cma__c_thkind_null)
#define cma__c_thkind__dim (cma__c_thkind__last + 1)
typedef enum CMA__T_SYSCALL_STATE {
cma__c_syscall_ok = 1,
cma__c_syscall_intintrpt = 1,
cma__c_syscall_extintrpt = 2
} cma__t_syscall_state;
typedef struct CMA__T_INT_TCB {
cma__t_object header;
cma__t_tcb_pad pad1;
cma_t_tcb_prolog prolog;
cma__t_queue threads;
cma__t_int_attr *attributes;
cma__t_state state;
cma__t_thkind kind;
struct CMA__T_INT_MUTEX
*mutex;
struct CMA__T_INT_CV
*term_cv;
struct CMA__T_INT_MUTEX
*tswait_mutex;
struct CMA__T_INT_CV
*tswait_cv;
cma_t_start_routine start_code;
cma_t_address start_arg;
cma__t_queue stack;
cma_t_natural context_count;
cma__t_context_list contexts;
cma_t_exit_status exit_status;
cma_t_address return_value;
cma__t_async_ctx async_ctx;
cma__t_static_ctx static_ctx;
cma_t_integer event_status;
cma__t_tcb_time timer;
cma__t_tcb_sched sched;
cma__t_tcb_debug debug;
#if _CMA_OS_ == _CMA__UNIX
# if !_CMA_THREAD_SYNC_IO_
cma__t_tcb_select select;
# endif
struct sigaction sigaction_data[NSIG];
#endif
cma_t_natural syscall_state;
cma_t_boolean detached;
cma_t_boolean terminated;
cma_t_integer joiners;
cma__t_int_alert alert;
struct CMA__T_INT_CV
*wait_cv;
struct CMA__T_INT_MUTEX
*wait_mutex;
struct EXC_CONTEXT_T
*exc_stack;
#if _CMA_PLATFORM_ == _CMA__IBMR2_UNIX
char ctx_stack[cma__c_ibmr2_ctx_stack_size];
#endif
cma_t_integer thd_errno;
#if _CMA_OS_ == _CMA__VMS
cma_t_integer thd_vmserrno;
#endif
} cma__t_int_tcb;
#endif