MicrOS
micros_process.h File Reference
#include <stdbool.h>
#include "../stdlib.h"
#include "micros_interrupts.h"

Go to the source code of this file.

Classes

struct  micros_process_user_info
 Process information retrieved from the kernel. More...
 
struct  micros_signal_registers_state
 Process registers state. More...
 
struct  micros_signal_fpu_state
 Process FPU state. More...
 
struct  micros_signal_params
 Structure containig data passed when the signal is executed (from the point where the last instruction was executed before signal) More...
 

Enumerations

enum  micros_process_status {
  micros_process_status_ready, micros_process_status_working, micros_process_status_waiting_sleep, micros_process_status_waiting_key_press,
  micros_process_status_waiting_for_process
}
 Process status retrieved from the kernel. More...
 

Functions

void micros_process_exit_process (int status)
 Forces current process to exit. More...
 
uint32_t micros_process_get_processes_count ()
 Returns number of processes. More...
 
void micros_process_get_current_process_info (micros_process_user_info *user_info)
 Retrieves from the kernel information about the current process. More...
 
bool micros_process_get_process_info (uint32_t id, micros_process_user_info *user_info)
 Retrieves from the kernel information about the process with the specified id. More...
 
void micros_process_get_all_processes_info (micros_process_user_info *user_info)
 Retrieves from the kernel information about all processes. More...
 
void micros_process_set_current_process_name (char *name)
 Sets name of the current process. More...
 
void micros_process_current_process_sleep (uint32_t milliseconds)
 Stops process for the specified amount of time. More...
 
uint32_t micros_process_start_process (char *path, char *arguments, bool child, bool active)
 Creates new process. More...
 
void micros_process_set_current_process_signal_handler (void(*signal_handler)(micros_signal_params *))
 Sets function which will be called on the signal raise. More...
 
void micros_process_finish_signal_handler (micros_signal_params *old_state)
 Confirms the end of signal handler execution. More...
 
void micros_process_wait_for_process (uint32_t process_id_to_wait)
 Stops process until the end of the another process. More...
 
uint32_t micros_process_start_thread (void *entry_point, void *param)
 Creates new thread. More...
 
void micros_process_abort_thread ()
 Forces current thread to exit. More...
 

Enumeration Type Documentation

◆ micros_process_status

Process status retrieved from the kernel.

Enumerator
micros_process_status_ready 

Process is ready to work and waits in queue.

micros_process_status_working 

Process is currently working.

micros_process_status_waiting_sleep 

Process has called sleep function and is stopped for the specified amount of time.

micros_process_status_waiting_key_press 

Process has called blocking keyboard function and waits for any pressed key.

micros_process_status_waiting_for_process 

Process waits for the end of the another process (like shell is waiting for the end of the child process)

Function Documentation

◆ micros_process_abort_thread()

void micros_process_abort_thread ( )

Forces current thread to exit.

Forces current thread to exit.

◆ micros_process_current_process_sleep()

void micros_process_current_process_sleep ( uint32_t  milliseconds)

Stops process for the specified amount of time.

Stops process for the specified amount of time. Kernel won't jump to this process until the time will pass.

Parameters
millisecondsMilliseconds to wait.

◆ micros_process_exit_process()

void micros_process_exit_process ( int  status)

Forces current process to exit.

Forces current process to exit with the specified status code (typically 0 means success).

Parameters
statusExit status code.

◆ micros_process_finish_signal_handler()

void micros_process_finish_signal_handler ( micros_signal_params old_state)

Confirms the end of signal handler execution.

Confirms the end of signal handler execution. Kernel will return to the last instruction before signal was raised.

Parameters
old_stateSignal state retrieved from the kernel.

◆ micros_process_get_all_processes_info()

void micros_process_get_all_processes_info ( micros_process_user_info user_info)

Retrieves from the kernel information about all processes.

Retrieves from the kernel information about all processes id and saves them to the passed structure.

Parameters
user_infoPointer to the structure where the information about all processes will be stored.

◆ micros_process_get_current_process_info()

void micros_process_get_current_process_info ( micros_process_user_info user_info)

Retrieves from the kernel information about the current process.

Retrieves from the kernel information about the current process and saves it to the passed structure.

Parameters
user_infoPointer to the structure where the information about the current process will be stored.

◆ micros_process_get_process_info()

bool micros_process_get_process_info ( uint32_t  id,
micros_process_user_info user_info 
)

Retrieves from the kernel information about the process with the specified id.

Retrieves from the kernel information about the process with the specified id and saves it to the passed structure.

Parameters
user_infoPointer to the structure where the information about the process with the specified id will be stored.
Returns
True if process with the specified ID was found, otherwise false.

◆ micros_process_get_processes_count()

uint32_t micros_process_get_processes_count ( )

Returns number of processes.

Returns number of processes working in the operating system.

Returns
Number of the working processes.

◆ micros_process_set_current_process_name()

void micros_process_set_current_process_name ( char *  name)

Sets name of the current process.

Sets name of the current process. Name cannot be longer than 32 chars.

Parameters
nameNew name of the current process.

◆ micros_process_set_current_process_signal_handler()

void micros_process_set_current_process_signal_handler ( void(*)(micros_signal_params *)  signal_handler)

Sets function which will be called on the signal raise.

Sets function which will be called on the signal raise. Should be called by the standard library before entering to the main function of the program.

Parameters
micros_signal_paramsPointer to the function.

◆ micros_process_start_process()

uint32_t micros_process_start_process ( char *  path,
char *  arguments,
bool  child,
bool  active 
)

Creates new process.

Creates new process from the specified path with parameters.

Parameters
pathPath to the executable file.
argumentsArguments passed to the main function of the new process.
childFlag indicates it the newly created process will be child of the current process.
activeFlag indicates if the newly created process will become active (on foreground).
Returns
ID of the create process.

◆ micros_process_start_thread()

uint32_t micros_process_start_thread ( void *  entry_point,
void *  param 
)

Creates new thread.

Creates new thread with the specified parameters.

Parameters
entry_pointAddress of the entry point from which thread will start.
paramParameter which will be passed to the thread function.
Returns
ID of the create thread.

◆ micros_process_wait_for_process()

void micros_process_wait_for_process ( uint32_t  process_id_to_wait)

Stops process until the end of the another process.

Stops process until the end of the another process with the specified ID.

Parameters
process_id_to_waitProcess ID to wait.