Pseudocode for semctl, semget and semop functions
This commit is contained in:
+73
-3
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user