2020-07-26 15:38:29 -05:00
|
|
|
/**
|
|
|
|
* \file
|
|
|
|
*/
|
|
|
|
|
2020-07-26 14:39:08 -05:00
|
|
|
#ifndef TASKING_H
|
|
|
|
#define TASKING_H
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
|
|
|
#ifndef KERN_TASKING_H
|
2020-07-26 15:38:29 -05:00
|
|
|
/**
|
|
|
|
* Represents the state of a thread
|
|
|
|
*/
|
2020-07-26 14:39:08 -05:00
|
|
|
typedef enum thread_state {
|
2020-07-26 15:38:29 -05:00
|
|
|
THREAD_RUNNING, //!< The state of a running thread
|
|
|
|
THREAD_READY, //!< The state of a ready to run thread
|
|
|
|
THREAD_EXITED, //!< The state of an exited thread
|
|
|
|
THREAD_BLOCKED //!< The state of a generically blocked thread
|
2020-07-26 14:39:08 -05:00
|
|
|
} thread_state;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2020-07-26 15:38:29 -05:00
|
|
|
/**
|
|
|
|
* Yield the CPU to another process
|
|
|
|
*/
|
2020-07-26 14:39:08 -05:00
|
|
|
void yield();
|
2020-07-26 15:38:29 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a process
|
|
|
|
* \param start The start function of the process
|
2020-07-29 07:27:12 -05:00
|
|
|
* \param address_space The address space of the process
|
2020-07-26 15:38:29 -05:00
|
|
|
* \param param1 The first parameter of the process
|
|
|
|
* \param param2 The second parameter of the process
|
|
|
|
*/
|
2020-07-29 10:35:04 -05:00
|
|
|
void create_proc(void* start,void* address_space,void* param1,void* param2);
|
2020-07-26 15:38:29 -05:00
|
|
|
/**
|
|
|
|
* Block the current thread
|
|
|
|
* \param state The state to block it with
|
|
|
|
*/
|
2020-07-29 08:09:53 -05:00
|
|
|
void block_thread(thread_state state);
|
2020-07-26 15:38:29 -05:00
|
|
|
/**
|
|
|
|
* Unblock a thread in a process
|
|
|
|
* \param pid The PID of the thread's process
|
|
|
|
* \param tid The TID of the thread
|
|
|
|
*/
|
2020-07-29 08:09:53 -05:00
|
|
|
void unblock_thread(pid_t pid,pid_t tid);
|
2020-07-26 14:39:08 -05:00
|
|
|
|
2020-08-02 14:37:23 -05:00
|
|
|
/**
|
|
|
|
* Check if a process exists
|
|
|
|
* \param pid The param of the process to check
|
|
|
|
* \return Whether the process exists
|
|
|
|
*/
|
|
|
|
char check_proc_exists(pid_t pid);
|
2020-07-26 14:39:08 -05:00
|
|
|
|
|
|
|
#endif
|