18#ifndef _COBALT_POSIX_PROCESS_H
19#define _COBALT_POSIX_PROCESS_H
21#include <linux/list.h>
22#include <linux/bitmap.h>
23#include <pipeline/thread.h>
24#include <cobalt/kernel/ppd.h>
26#define NR_PERSONALITIES 4
27#if BITS_PER_LONG < NR_PERSONALITIES
28#error "NR_PERSONALITIES overflows internal bitmap"
32struct xnthread_personality;
35struct cobalt_resources {
36 struct list_head condq;
37 struct list_head mutexq;
38 struct list_head semq;
39 struct list_head monitorq;
40 struct list_head eventq;
41 struct list_head schedq;
44struct cobalt_process {
46 struct hlist_node hlink;
47 struct cobalt_ppd sys_ppd;
50 struct list_head sigwaiters;
51 struct cobalt_resources resources;
52 struct list_head thread_list;
53 DECLARE_BITMAP(timers_map, CONFIG_XENO_OPT_NRTIMERS);
54 struct cobalt_timer *timers[CONFIG_XENO_OPT_NRTIMERS];
55 void *priv[NR_PERSONALITIES];
57 unsigned int debugged_threads;
60struct cobalt_resnode {
61 struct cobalt_resources *scope;
62 struct cobalt_process *owner;
63 struct list_head next;
67int cobalt_register_personality(
struct xnthread_personality *personality);
69int cobalt_unregister_personality(
int xid);
71struct xnthread_personality *cobalt_push_personality(
int xid);
73void cobalt_pop_personality(
struct xnthread_personality *prev);
75int cobalt_bind_core(
int ufeatures);
77int cobalt_bind_personality(
unsigned int magic);
79struct cobalt_process *cobalt_search_process(
struct mm_struct *mm);
81int cobalt_map_user(
struct xnthread *thread, __u32 __user *u_winoff);
83void *cobalt_get_context(
int xid);
85int cobalt_yield(xnticks_t min, xnticks_t max);
87int cobalt_process_init(
void);
89extern struct list_head cobalt_global_thread_list;
91extern struct cobalt_resources cobalt_global_resources;
93static inline struct cobalt_process *cobalt_current_process(
void)
95 return pipeline_current()->process;
98static inline struct cobalt_process *
99cobalt_set_process(
struct cobalt_process *process)
101 struct cobalt_threadinfo *p = pipeline_current();
102 struct cobalt_process *old;
105 p->process = process;
110static inline struct cobalt_ppd *cobalt_ppd_get(
int global)
112 struct cobalt_process *process;
114 if (global || (process = cobalt_current_process()) == NULL)
115 return &cobalt_kernel_ppd;
117 return &process->sys_ppd;
120static inline struct cobalt_resources *cobalt_current_resources(
int pshared)
122 struct cobalt_process *process;
124 if (pshared || (process = cobalt_current_process()) == NULL)
125 return &cobalt_global_resources;
127 return &process->resources;
131void __cobalt_add_resource(
struct cobalt_resnode *node,
int pshared)
133 node->owner = cobalt_current_process();
134 node->scope = cobalt_current_resources(pshared);
137#define cobalt_add_resource(__node, __type, __pshared) \
139 __cobalt_add_resource(__node, __pshared); \
140 list_add_tail(&(__node)->next, \
141 &((__node)->scope)->__type ## q); \
145void cobalt_del_resource(
struct cobalt_resnode *node)
147 list_del(&node->next);
150void cobalt_remove_process(
struct cobalt_process *process);
152void cobalt_signal_yield(
void);
154void cobalt_stop_debugged_process(
struct xnthread *thread);
156void cobalt_register_debugged_thread(
struct xnthread *thread);
158void cobalt_unregister_debugged_thread(
struct xnthread *thread);
160extern struct xnthread_personality *cobalt_personalities[];
162extern struct xnthread_personality cobalt_personality;
164int cobalt_handle_setaffinity_event(
struct task_struct *task);
167void cobalt_adjust_affinity(
struct task_struct *task);
169static inline void cobalt_adjust_affinity(
struct task_struct *task) { }
172int cobalt_handle_taskexit_event(
struct task_struct *task);
174int cobalt_handle_cleanup_event(
struct mm_struct *mm);
176int cobalt_handle_user_return(
struct task_struct *task);