MentOS  0.8.0
The Mentoring Operating System
process.h
Go to the documentation of this file.
1 
6 #pragma once
7 
9 #include "bits/termios-struct.h"
10 #include "system/signal.h"
11 #include "devices/fpu.h"
12 #include "mem/paging.h"
13 #include "stdbool.h"
14 
16 #define TASK_NAME_MAX_LENGTH 100
17 
19 #define DEFAULT_STACK_SIZE (1 * M)
20 
32 typedef struct sched_entity_t {
34  int prio;
35 
46 
66 
68 typedef struct thread_struct_t {
78 
82 typedef struct task_struct {
97  // -1 unrunnable, 0 runnable, >0 stopped.
99  __volatile__ long state;
103  int max_fd;
107  list_head run_list;
109  list_head children;
111  list_head sibling;
123  int error_no;
125  char cwd[PATH_MAX];
126 
139 
142 
144  unsigned long it_real_incr;
146  unsigned long it_real_value;
148  unsigned long it_virt_incr;
150  unsigned long it_virt_value;
152  unsigned long it_prof_incr;
154  unsigned long it_prof_value;
155 
159  fs_rb_scancode_t keyboard_rb;
160 
161  //==== Future work =========================================================
162  // - task's attributes:
163  // struct task_struct __rcu *real_parent;
164  // int exit_state;
165  // int exit_signal;
166  // struct thread_info thread_info;
167  //==========================================================================
169 
172 int init_tasking(void);
173 
177 task_struct *process_create_init(const char *path);
Floating Point Unit (FPU).
Drivers for the Keyboard devices.
#define PATH_MAX
Maximum number of characters in a path name.
Definition: limits.h:54
signed int pid_t
The type of process id.
Definition: types.h:9
Signals definition.
Implementation of a memory paging management.
struct sched_entity_t sched_entity_t
This structure is used to track the statistics of a process.
#define TASK_NAME_MAX_LENGTH
The maximum length of a name for a task_struct.
Definition: process.h:16
task_struct * process_create_init(const char *path)
Create and spawn the init process.
Definition: process.c:343
struct task_struct task_struct
this is our task object. Every process in the system has this, and it holds a lot of information....
struct thread_struct_t thread_struct_t
Stores the status of CPU and FPU registers.
int init_tasking(void)
Initialize the task management.
Definition: process.c:335
Defines the boolean values.
bool_t
Define boolean value.
Definition: stdbool.h:9
int uid_t
The type of user-id.
Definition: stddef.h:40
unsigned int uint32_t
Define the unsigned 32-bit integer.
Definition: stdint.h:18
Memory Descriptor, used to store details about the memory of a user process.
Definition: paging.h:109
Interrupt stack frame.
Definition: kernel.h:24
This structure is used to track the statistics of a process.
Definition: process.h:32
time_t worst_case_exec
Worst case execution time.
Definition: process.h:62
time_t period
Expected period of the task.
Definition: process.h:48
time_t vruntime
Weighted execution time.
Definition: process.h:45
bool_t is_under_analysis
Determines if we need to analyze the WCET of the process.
Definition: process.h:58
time_t next_period
Beginning of next period.
Definition: process.h:60
time_t exec_runtime
Last execution time.
Definition: process.h:41
time_t start_runtime
Start execution time.
Definition: process.h:37
bool_t is_periodic
Determines if it is a periodic task.
Definition: process.h:56
time_t deadline
Absolute deadline.
Definition: process.h:50
time_t arrivaltime
Absolute time of arrival of the task.
Definition: process.h:52
time_t sum_exec_runtime
Overall execution time.
Definition: process.h:43
int prio
Static execution priority.
Definition: process.h:34
time_t exec_start
Last context switch time.
Definition: process.h:39
double utilization_factor
Processor utilization factor.
Definition: process.h:64
bool_t executed
Has already executed.
Definition: process.h:54
Describes how each signal must be handled.
Definition: signal.h:186
Keeps information of pending signals.
Definition: signal.h:236
Structure used to mask and unmask signals.
Definition: signal.h:167
this is our task object. Every process in the system has this, and it holds a lot of information....
Definition: process.h:82
unsigned long it_virt_incr
Next value for the virtual timer (ITIMER_VIRTUAL).
Definition: process.h:148
sigpending_t pending
Data structure storing the private pending signals.
Definition: process.h:138
vfs_file_descriptor_t * fd_list
The current opened file descriptors.
Definition: process.h:101
sigset_t blocked
Mask of blocked signals.
Definition: process.h:132
list_head sibling
List of siblings, namely processes created by parent process.
Definition: process.h:111
sighand_t sighand
Pointer to the process’s signal handler descriptor.
Definition: process.h:130
sched_entity_t se
For scheduling algorithms.
Definition: process.h:115
pid_t gid
The effective Group ID (GID) of the process.
Definition: process.h:92
uid_t ruid
The User ID (UID) of the user owning the process.
Definition: process.h:94
char name[TASK_NAME_MAX_LENGTH]
The name of the task (Added for debug purpose).
Definition: process.h:119
struct timer_list * real_timer
Timer for alarm syscall.
Definition: process.h:141
int max_fd
The maximum supported number of file descriptors.
Definition: process.h:103
pid_t pgid
The Process Group Id of the process.
Definition: process.h:88
unsigned long it_prof_incr
Next value for the profiling timer (ITIMER_PROF).
Definition: process.h:152
pid_t rgid
The Group ID (GID) of the process.
Definition: process.h:90
unsigned long it_virt_value
Current value for the virtual timer (ITIMER_VIRTUAL).
Definition: process.h:150
char cwd[PATH_MAX]
The current working directory.
Definition: process.h:125
fs_rb_scancode_t keyboard_rb
Buffer for managing inputs from keyboard.
Definition: process.h:159
thread_struct_t thread
The context of the processors.
Definition: process.h:113
__volatile__ long state
The current state of the process:
Definition: process.h:99
uint32_t sigreturn_addr
Address of the LIBC sigreturn function.
Definition: process.h:128
list_head children
List of children traced by the process.
Definition: process.h:109
termios_t termios
Process-wise terminal options.
Definition: process.h:157
unsigned long it_real_value
Current value for the real timer (ITIMER_REAL).
Definition: process.h:146
sigset_t real_blocked
Temporary mask of blocked signals (used by the rt_sigtimedwait() system call)
Definition: process.h:134
int error_no
Task's specific error number.
Definition: process.h:123
int exit_code
Exit code of the process. (parameter of _exit() system call).
Definition: process.h:117
unsigned long it_real_incr
Next value for the real timer (ITIMER_REAL).
Definition: process.h:144
uid_t uid
The effective User ID (UID) of the process.
Definition: process.h:96
sigset_t saved_sigmask
The previous sig mask.
Definition: process.h:136
unsigned long it_prof_value
Current value for the profiling timer (ITIMER_PROF).
Definition: process.h:154
mm_struct_t * mm
Task's segments.
Definition: process.h:121
struct task_struct * parent
Pointer to process's parent.
Definition: process.h:105
list_head run_list
List head for scheduling purposes.
Definition: process.h:107
pid_t sid
The session id of the process.
Definition: process.h:86
pid_t pid
The pid of the process.
Definition: process.h:84
Stores information about a terminal IOs.
Definition: termios-struct.h:18
Stores the status of CPU and FPU registers.
Definition: process.h:68
savefpu fpu_register
Data structure used to save FPU registers.
Definition: process.h:76
pt_regs regs
Stored status of registers.
Definition: process.h:70
bool_t fpu_enabled
Determines if the FPU is enabled.
Definition: process.h:74
pt_regs signal_regs
Stored status of registers befor jumping into a signal handler.
Definition: process.h:72
Represents the request to execute a function in the future, also known as timer.
Definition: timer.h:113
Data structure containing information about an open file.
Definition: vfs_types.h:170
Definition of the termios structure.
unsigned int time_t
Used to store time values.
Definition: time.h:22
Stores FPU registers details.
Definition: fpu.h:113