RocketLogger  1.1.4
sem.c File Reference
#include <fcntl.h>
#include <sys/ipc.h>
#include <sys/sem.h>
#include <sys/types.h>
#include "sem.h"
+ Include dependency graph for sem.c:

Go to the source code of this file.

Macros

#define _GNU_SOURCE
 

Functions

int create_sem (key_t key, int num_sems)
 
int remove_sem (int sem_id)
 
int open_sem (key_t key, int num_sems)
 
int wait_sem (int sem_id, int sem_num, int time_out)
 
int set_sem (int sem_id, int sem_num, int val)
 

Macro Definition Documentation

#define _GNU_SOURCE

Copyright (c) 2016-2018, Swiss Federal Institute of Technology (ETH Zurich) All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  • Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Definition at line 32 of file sem.c.

Function Documentation

int create_sem ( key_t  key,
int  num_sems 
)

Create RocketLogger semaphore set

Returns
ID of created set

Definition at line 46 of file sem.c.

References ERROR, rl_log(), and sem_id.

Referenced by pru_sample().

+ Here is the call graph for this function:

int open_sem ( key_t  key,
int  num_sems 
)

Open existing RocketLogger semaphore set

Returns
ID of opened set

Definition at line 72 of file sem.c.

References ERROR, rl_log(), and sem_id.

Referenced by main().

+ Here is the call graph for this function:

int remove_sem ( int  sem_id)

Remove semaphore set

Parameters
sem_idID of set to remove
Returns
SUCCESS on success, FAILURE otherwise

Definition at line 59 of file sem.c.

References ERROR, FAILURE, rl_log(), and SUCCESS.

Referenced by pru_sample().

+ Here is the call graph for this function:

int set_sem ( int  sem_id,
int  sem_num,
int  val 
)

Set value to semaphore

Parameters
sem_idID of semaphore set
sem_numNumber of semaphore in set
valValue to be set to semaphore
Returns
SUCCESS on success (access granted), TIME_OUT on time out, FAILURE otherwise

Definition at line 124 of file sem.c.

References ERROR, FAILURE, NO_FLAG, rl_log(), SEM_SET_TIME_OUT, SUCCESS, and TIME_OUT.

Referenced by main(), print_data(), pru_sample(), and web_handle_data().

+ Here is the call graph for this function:

int wait_sem ( int  sem_id,
int  sem_num,
int  time_out 
)

Wait on a semaphore until access granted

Parameters
sem_idID of semaphore set
sem_numNumber of semaphore in set
time_outMaximum waiting time
Returns
SUCCESS on success (access granted), TIME_OUT on time out, FAILURE otherwise

Definition at line 88 of file sem.c.

References ERROR, FAILURE, INFO, NO_FLAG, rl_log(), SUCCESS, TIME_OUT, and WARNING.

Referenced by main(), print_data(), and web_handle_data().

+ Here is the call graph for this function: