18 #ifndef _COBALT_POSIX_PROCESS_H 19 #define _COBALT_POSIX_PROCESS_H 21 #include <linux/list.h> 22 #include <linux/bitmap.h> 23 #include <cobalt/kernel/ppd.h> 25 #define KEVENT_PROPAGATE 0 28 #define NR_PERSONALITIES 4 29 #if BITS_PER_LONG < NR_PERSONALITIES 30 #error "NR_PERSONALITIES overflows internal bitmap" 34 struct xnthread_personality;
37 struct cobalt_resources {
38 struct list_head condq;
39 struct list_head mutexq;
40 struct list_head semq;
41 struct list_head monitorq;
42 struct list_head eventq;
43 struct list_head schedq;
46 struct cobalt_process {
48 struct hlist_node hlink;
49 struct cobalt_ppd sys_ppd;
52 struct list_head sigwaiters;
53 struct cobalt_resources resources;
54 DECLARE_BITMAP(timers_map, CONFIG_XENO_OPT_NRTIMERS);
55 struct cobalt_timer *timers[CONFIG_XENO_OPT_NRTIMERS];
56 void *priv[NR_PERSONALITIES];
59 struct cobalt_resnode {
60 struct cobalt_resources *scope;
61 struct cobalt_process *owner;
62 struct list_head next;
66 int cobalt_register_personality(
struct xnthread_personality *personality);
68 int cobalt_unregister_personality(
int xid);
70 struct xnthread_personality *cobalt_push_personality(
int xid);
72 void cobalt_pop_personality(
struct xnthread_personality *prev);
74 int cobalt_bind_core(
void);
76 int cobalt_bind_personality(
unsigned int magic);
78 struct cobalt_process *cobalt_search_process(
struct mm_struct *mm);
80 int cobalt_map_user(
struct xnthread *thread, __u32 __user *u_winoff);
82 void *cobalt_get_context(
int xid);
84 int cobalt_yield(xnticks_t min, xnticks_t max);
86 int cobalt_process_init(
void);
88 extern struct list_head cobalt_thread_list;
90 extern struct cobalt_resources cobalt_global_resources;
92 static inline struct cobalt_process *cobalt_current_process(
void)
94 return ipipe_current_threadinfo()->process;
97 static inline struct cobalt_process *
98 cobalt_set_process(
struct cobalt_process *process)
100 struct ipipe_threadinfo *p = ipipe_current_threadinfo();
101 struct cobalt_process *old;
104 p->process = process;
109 static inline struct cobalt_ppd *cobalt_ppd_get(
int global)
111 struct cobalt_process *process;
113 if (global || (process = cobalt_current_process()) == NULL)
114 return &cobalt_kernel_ppd;
116 return &process->sys_ppd;
119 static inline struct cobalt_resources *cobalt_current_resources(
int pshared)
121 struct cobalt_process *process;
123 if (pshared || (process = cobalt_current_process()) == NULL)
124 return &cobalt_global_resources;
126 return &process->resources;
130 void __cobalt_add_resource(
struct cobalt_resnode *node,
int pshared)
132 node->owner = cobalt_current_process();
133 node->scope = cobalt_current_resources(pshared);
136 #define cobalt_add_resource(__node, __type, __pshared) \ 138 __cobalt_add_resource(__node, __pshared); \ 139 list_add_tail(&(__node)->next, \ 140 &((__node)->scope)->__type ## q); \ 144 void cobalt_del_resource(
struct cobalt_resnode *node)
146 list_del(&node->next);
149 extern struct xnthread_personality *cobalt_personalities[];
151 extern struct xnthread_personality cobalt_personality;