OctopOS  0.6.0
Data communication bus for SPACE HAUC
Classes | Macros | Typedefs | Functions | Variables
utility.h File Reference
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <sys/msg.h>
#include <sys/sem.h>
#include <exception>
#include <system_error>
#include <cerrno>

Go to the source code of this file.

Classes

struct  shm_object
 
struct  message_buffer
 
union  semun
 

Macros

#define MEMKEY   0x45861534
 
#define SEMKEY   0x45861534
 
#define MSGKEY   0x45861534
 
#define MSGLEN   126
 
#define SHMSIZE   4096
 

Typedefs

typedef intptr_t generic_t
 
typedef long octopOS_id_t
 
typedef uint sem_id_t
 

Functions

intptr_t * connect_shm ()
 
int p (int sem, int counter)
 
int v (int sem, int counter)
 
int semsetall (int sem_group, int number_in_group, int value)
 

Variables

const unsigned NUMMODULES = 20
 
const unsigned SUB_BIT = 0x20000000
 
const unsigned TEMP_BIT = 0x40000000
 
const unsigned CREATE_PUB = 1
 
const unsigned PUBLISH_CODE = 2
 
const unsigned CREATE_SUB = 3
 

Typedef Documentation

◆ generic_t

typedef intptr_t generic_t

typedef for generic pointers in shared memory segment

◆ octopOS_id_t

typedef long octopOS_id_t

typedef to increase readability

◆ sem_id_t

typedef uint sem_id_t

typedef to make Lukas happy

Function Documentation

◆ connect_shm()

intptr_t* connect_shm ( )

function for connecting shared memmory to address space.

Returns
A pointer to the top of the shared memory space

◆ p()

int p ( int  sem,
int  counter 
)

Decraments a semaphore.

Parameters
semThe semaphore to access
counterthe counter to decrament
Returns
value of system call. fail if < 0.

◆ semsetall()

int semsetall ( int  sem_group,
int  number_in_group,
int  value 
)

Initializes all counters in a semaphore.

Parameters
sem_groupThe semaphore to initializes.
number_in_groupNumber of counters in the group.
valueThe initial value to set.
Returns
value of system call. fail if < 0.

◆ v()

int v ( int  sem,
int  counter 
)

Incraments a semaphore.

Parameters
semThe semaphore to access
counterthe counter to incraments
Returns
value of system call. fail if < 0.

Variable Documentation

◆ CREATE_PUB

const unsigned CREATE_PUB = 1

packet type is requesting creation of publisher

◆ CREATE_SUB

const unsigned CREATE_SUB = 3

packet type is requesting creation of subscriber

◆ NUMMODULES

const unsigned NUMMODULES = 20

The number of modules octopOS will start

◆ PUBLISH_CODE

const unsigned PUBLISH_CODE = 2

packet type is requesting notification of subscribers

◆ SUB_BIT

const unsigned SUB_BIT = 0x20000000

The subscriber bit that needs to be set in ids

◆ TEMP_BIT

const unsigned TEMP_BIT = 0x40000000

The bit in ids that specifies it is a temp id