Pseudocode for semctl, semget and semop functions

This commit is contained in:
Aldegheri Alessandro
2023-03-29 17:27:38 +02:00
parent 25c1c2c6fb
commit cd74fd521c
2 changed files with 75 additions and 5 deletions
+73 -3
View File
@@ -17,20 +17,90 @@
//test
long sys_semget(key_t key, int nsems, int semflg)
{
printf("qui");
/*PSEUDOCODE (todo)*/
/*
Check if num_sems is a valid value
*/
/* .... */
/*
Compute the IPC id using key. (Hashing Algorithm?)
*/
/* .... */
/*
Check if a semaphore set with the ID already exists (and then check for IPC_EXCL flag)
*/
/* .... */
/*
If the semaphore does not exist, create a new semaphore set with the specified number of sems
(allocation, initialization...)
*/
/* .... */
/*
Set the semaphore set permissions (default 0666)
*/
/* .... */
/*
Return the new semaphore set ID
*/
/* .... */
//printf("qui"); test
//TODO("Not implemented");
return 0;
}
long sys_semop(int semid, struct sembuf *sops, unsigned nsops)
{
TODO("Not implemented");
/*
Check if semid is a valid semaphore set identifier
*/
/* .... */
/*
Handle the sembuf structure and perform the operation (spinlocks?)
*/
/* .... */
/*
Update the semaphores values
*/
/* .... */
//TODO("Not implemented");
return 0;
}
long sys_semctl(int semid, int semnum, int cmd, unsigned long arg)
{
TODO("Not implemented");
/*
Check if semid is a valid semaphore identifier
*/
/* .... */
/*
Check the cmd parameter (GETVAL, SETVAL...) and perform the operation
*/
/* .... */
//TODO("Not implemented");
return 0;
}
+2 -2
View File
@@ -1,8 +1,8 @@
//testtt
//test
#include <ipc/sem.h>
int main()
{
long i = semget(0,0,0);
long i = semget(0,0,0); //checking if the syscalls are already linked
return 0;
}