#ifndef TASK_H #define TASK_H #include #include #define TASK_NAME_LEN 15 #define MAX_WAITS 16 struct wait { enum { NONE, PROCESS_END, WINDOW_ACTION, IPC_RECEIVE, IPC_RECEIVE_ANY, IPC_SEND } mode; union { struct task_state *task; }; }; struct task_state { uint32_t ret_addr; void *page_directory; uint32_t ebx; uint32_t ecx; uint32_t edx; uint32_t esi; uint32_t edi; uint32_t ebp; uint32_t esp; uint32_t stack_bottom; struct wait waits[MAX_WAITS]; bool waiting; char name[TASK_NAME_LEN + 1]; } __attribute__ ((packed)); void add_wait(struct wait wait); void unwait_any(struct wait wait); void unwait(struct task_state *task, struct wait wait); extern struct task_state tasks[]; extern struct task_state *active_task; void init_tasks(); uint32_t new_task(struct task_state state); void advance_active_task(); void delete_task(struct task_state *state); uint32_t ipc_send(uint32_t reader_handle, uint32_t count, const void *buffer); uint32_t ipc_read(uint32_t sender_handle, uint32_t count, void *buffer); uint32_t find_unread_ipc(); #endif