Processes

Name

Processes -- Process Handling.

Synopsis


proc_t*     create_process                  (void);
proc_t*     new_process                     (void);
void        insert_process                  (proc_t *proc);
void        free_process                    (proc_t *proc);
gint        destroy_process                 (proc_t *proc);
proc_queue_t get_proc_list                  (void);
proc_t*     get_proc_by_pid                 (gint pid);
void        select_process                  (proc_t *proc);
proc_t*     get_CPU_selected_proc           (void);
void        save_processes_to_file          (void);
void        load_processes_from_file        (void);
#define     burst                           (proc)

Description

This functions provide general process handling. Creation, insertion into the system, destruction, finding a certain process...

Details

create_process ()

proc_t*     create_process                  (void);

Do everything necesary to have a new process in the system.

Returns : the newly created process.


new_process ()

proc_t*     new_process                     (void);

Allocate data for new process.

Note: the process will have to be inserted to have any efect.

Returns : the newly allocate process data.


insert_process ()

void        insert_process                  (proc_t *proc);

Inserts process proc in the system.

Note: proc can be obtained with new_process.

proc : the process involved.


free_process ()

void        free_process                    (proc_t *proc);

Definitely free all data related to proc.

Note: proc will be gone for good.

proc : process involved.


destroy_process ()

gint        destroy_process                 (proc_t *proc);

Start considering proc a terminated process and remove it from the system.

Note: the data of proc is not freed, and proc will be saved by save_processes_to_file.

proc : process involved.
Returns : nothing important.


get_proc_list ()

proc_queue_t get_proc_list                  (void);

Returns : the list of all currently running processes.


get_proc_by_pid ()

proc_t*     get_proc_by_pid                 (gint pid);

pid : process ID
Returns : the data of process pid or NULL if there is no process with PID pid.


select_process ()

void        select_process                  (proc_t *proc);

Makes proc the selected process.

Note: some code will do things to the selected process.

proc : process involved.


get_CPU_selected_proc ()

proc_t*     get_CPU_selected_proc           (void);

Find out which is the currently selected process

Returns : the currently selected process.


save_processes_to_file ()

void        save_processes_to_file          (void);

Asks the user for a filename and saves all processes on the current session to a file, ready to be loaded in a new session.

Note: Both terminated and not yet running processes will be written.


load_processes_from_file ()

void        load_processes_from_file        (void);

Asks the user for a filename and loads all processes it can find it it.

Note: Not all processes will be visible at once, they will be inserted at the right time.


burst()

#define burst(proc) (proc->next_event.time - proc->time)

Calculates the current burst (time until next voluntary event) for proc.

proc : process involved.