#ifndef KERNEL_TASK_H_ #define KERNEL_TASK_H_ #include #include #include #define TASK_NAME_MAX 64 #define PID_MAX 99999 struct channel; enum task_state { TASK_RUNNING, TASK_STOPPED, }; struct task { struct object t_base; struct task *t_parent; long t_id; enum task_state t_state; char t_name[TASK_NAME_MAX]; pmap_t t_pmap; struct vm_region *t_address_space; spin_lock_t t_handles_lock; struct handle_table *t_handles; struct btree b_channels; struct btree_node t_tasklist; struct queue_entry t_child_entry; size_t t_next_thread_id; struct queue t_threads; struct queue t_children; }; extern struct task *task_alloc(void); extern struct task *task_cast(struct object *obj); extern struct task *task_create(const char *name, size_t name_len); static inline struct task *task_ref(struct task *task) { return OBJECT_CAST(struct task, t_base, object_ref(&task->t_base)); } static inline void task_unref(struct task *task) { object_unref(&task->t_base); } extern kern_status_t task_add_child(struct task *parent, struct task *child); extern kern_status_t task_add_channel( struct task *task, struct channel *channel, unsigned int id); extern struct channel *task_get_channel(struct task *task, unsigned int id); extern struct task *task_from_tid(tid_t id); extern kern_status_t task_open_handle( struct task *task, struct object *obj, handle_flags_t flags, kern_handle_t *out); extern kern_status_t task_resolve_handle( struct task *task, kern_handle_t handle, struct object **out_obj, handle_flags_t *out_flags); extern kern_status_t task_close_handle(struct task *task, kern_handle_t handle); extern struct thread *task_create_thread(struct task *parent); extern struct task *kernel_task(void); extern struct task *idle_task(void); DEFINE_OBJECT_LOCK_FUNCTION(task, t_base) #endif