rasProject_01 / weSweetHome
R. 240
process control / RasPi software by weinert-automation
|
Shared memory on Raspberry Pis. More...
#include "weUtil.h"
#include <sys/shm.h>
#include <sys/stat.h>
#include <sys/sem.h>
#include <errno.h>
Data Structures | |
union | semCtlPar_t |
Parameter type for semctl(). More... | |
Macros | |
#define | PERM |
access rights | |
Functions | |
int | deleteSemas () |
Delete the one semaphore set. More... | |
int | deleteSharedMem () |
Delete and detach the shared memory. More... | |
int | detachSharedMem () |
Detach the shared memory. | |
int | getSemas () |
Get the one semaphore set. More... | |
int | initialiseSemas () |
Initialise the one semaphore set. More... | |
void * | initialiseSharedMem () |
Initialise shared memory. More... | |
int | semaphoreClt (int const semNum, int const op, semCtlPar_t par) |
Control semaphores of the set. More... | |
int | semaphoreLock (int const semNum, int ms) |
Lock one semaphore of the set. More... | |
int | semaphoreOperation (int const semNum, int const op, int ms) |
Operation on one semaphore of the set. More... | |
int | semaphoreUnlock (int const semNum) |
Unlock one semaphore of the set. More... | |
Variables | |
const semCtlPar_t | VAL0 |
value 0 for SETVAL | |
const semCtlPar_t | VAL1 |
value 1 for SETVAL | |
const semCtlPar_t | VAL9 |
value 9 for SETVAL | |
Shared memory on Raspberry Pis.
Revision history
Provide one shared memory range of size ... to be used by one or more C (or PHP or ...) programs on a Raspberry Pi3.
int getSemas | ( | ) |
Get the one semaphore set.
The one semaphore set, if existing, will be registered and used as is.
int initialiseSemas | ( | ) |
Initialise the one semaphore set.
The number of semaphores in the set is ANZ_SEMAS (default three). The one semaphore set, if existing, will be registered and used as is. If this is not possible it will be made and initialised.
Hint: This function has two OK return values!
int semaphoreOperation | ( | int const | semNum, |
int const | op, | ||
int | ms | ||
) |
Operation on one semaphore of the set.
semNum | the semaphore number in the set (0..ANZ_SEMAS -1) |
op | the semaphore operation |
ms | if 2..20000 a timeout in ms |
int semaphoreLock | ( | int const | semNum, |
int | ms | ||
) |
Lock one semaphore of the set.
semNum | the semaphore number in the set (0..ANZ_SEMAS -1) |
ms | if 2..20000 a timeout in ms |
int semaphoreUnlock | ( | int const | semNum | ) |
Unlock one semaphore of the set.
semNum | the semaphore number in the set (0..ANZ_SEMAS -1) |
int semaphoreClt | ( | int const | semNum, |
int const | op, | ||
semCtlPar_t | par | ||
) |
Control semaphores of the set.
semNum | the semaphore number in the set (0..ANZ_SEMAS -1) |
op | the semaphore operation, like e.g. SETVAL |
par | op's parameter if any |
int deleteSemas | ( | ) |
Delete the one semaphore set.
Server operation only.
void * initialiseSharedMem | ( | ) |
Initialise shared memory.
Make or get and attach. return pointer to attached shared memory or (void *)-1
int deleteSharedMem | ( | ) |
Delete and detach the shared memory.
Server operation only.