MentOS
0.8.0
The Mentoring Operating System
|
Classes | |
struct | sem_info_t |
Semaphore management structure. More... | |
Macros | |
#define | __DEBUG_HEADER__ "[IPCsem]" |
Change header. | |
#define | __DEBUG_LEVEL__ LOGLEVEL_NOTICE |
Set log level. | |
Functions | |
static sem_info_t * | __sem_info_alloc (key_t key, int nsems, int semflg) |
Allocates the memory for semaphore management structure. More... | |
static void | __sem_info_dealloc (sem_info_t *sem_info) |
Frees the memory of a semaphore management structure. More... | |
static sem_info_t * | __list_find_sem_info_by_id (int semid) |
Searches for the semaphore with the given id. More... | |
static sem_info_t * | __list_find_sem_info_by_key (key_t key) |
Searches for the semaphore with the given key. More... | |
static void | __list_add_sem_info (sem_info_t *sem_info) |
Adds the structure to the global list. More... | |
static void | __list_remove_sem_info (sem_info_t *sem_info) |
Removes the structure from the global list. More... | |
int | sem_init (void) |
Iinitializes the semaphore system. More... | |
long | sys_semget (key_t key, int nsems, int semflg) |
long | sys_semop (int semid, struct sembuf *sops, unsigned nsops) |
long | sys_semctl (int semid, int semnum, int cmd, union semun *arg) |
ssize_t | procipc_sem_read (vfs_file_t *file, char *buf, off_t offset, size_t nbyte) |
Read function for the proc system. More... | |
Variables | |
int | __sem_id = 0 |
A value to compute the semid value. | |
list_head | semaphores_list |
List of all current active semaphores. | |
At the moment we have various functions with their description (see comments). The first time that the function semget is called, we are going to generate the list and the first semaphore set with the assumption that we are not given a IPC_PRIVATE key (temporary ofc). We are able to create new semaphores set and generate unique keys (IPC_PRIVATE) with a counter that searches for the first possible key to assign. Temporary idea:
Right now we have a first version of working semaphores in MentOS. We have completed the semctl function and we have implemented the first version of the semop function both user and kernel side. The way it works is pretty straightforward, the user tries to perform an operation and based on the value of the semaphore the kernel returns certain values. If the operation cannot be performed then the user will stay in a while loop. The cycle ends with a positive return value (the operation has been taken care of) or in case of errors. For testing purposes -> you can try the t_semget and the t_sem1 tests. They both use semaphores and blocking / non blocking operations. t_sem1 is also an exercise that was assingned by Professor Drago in the OS course.
|
inlinestatic |
Adds the structure to the global list.
sem_info | the structure to add. |
|
inlinestatic |
Searches for the semaphore with the given id.
semid | the id we are searching. |
|
inlinestatic |
Searches for the semaphore with the given key.
key | the key we are searching. |
|
inlinestatic |
Removes the structure from the global list.
sem_info | the structure to remove. |
|
inlinestatic |
Allocates the memory for semaphore management structure.
key | IPC_KEY associated with the set of semaphores. |
nsems | number of semaphores to initialize. |
semflg | flags used to create the set of semaphores. |
|
inlinestatic |
Frees the memory of a semaphore management structure.
sem_info | pointer to the semaphore management structure. |
ssize_t procipc_sem_read | ( | vfs_file_t * | file, |
char * | buf, | ||
off_t | offset, | ||
size_t | nbyte | ||
) |
Read function for the proc system.
file | The file. |
buf | Buffer where the read content must be placed. |
offset | Offset from which we start reading from the file. |
nbyte | The number of bytes to read. |
int sem_init | ( | void | ) |
Iinitializes the semaphore system.