PICSimLab - Programmable IC Simulator Laboratory
0.9.2
PICSimLab - API
Loading...
Searching...
No Matches
ipc_smem.h
1
/* ########################################################################
2
3
PICSimLab - Programmable IC Simulator Laboratory
4
5
########################################################################
6
7
Copyright (c) : 2023-2024 Luis Claudio GambĂ´a Lopes <lcgamboa@yahoo.com>
8
9
This program is free software; you can redistribute it and/or modify
10
it under the terms of the GNU General Public License as published by
11
the Free Software Foundation; either version 2, or (at your option)
12
any later version.
13
14
This program is distributed in the hope that it will be useful,
15
but WITHOUT ANY WARRANTY; without even the implied warranty of
16
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
GNU General Public License for more details.
18
19
You should have received a copy of the GNU General Public License
20
along with this program; if not, write to the Free Software
21
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22
23
For e-mail suggestions : lcgamboa@yahoo.com
24
######################################################################## */
25
26
#ifndef IPC_SMEM
27
#define IPC_SMEM
28
29
#include <stdio.h>
30
#include <stdlib.h>
31
#include <string.h>
32
#include <unistd.h>
33
34
#ifdef _WIN_
35
#include <conio.h>
36
#include <windows.h>
37
typedef
struct
{
38
void
* pMem;
39
unsigned
int
size;
40
char
key[256];
41
HANDLE hMap;
42
HANDLE hsemid[2];
43
}
shared_block_t
;
44
45
#else
// LINUX
46
#include <fcntl.h>
47
#include <semaphore.h>
48
#include <sys/mman.h>
49
#include <time.h>
50
typedef
struct
{
51
void
* pMem;
52
unsigned
int
size;
53
char
key[256];
54
sem_t* semid[2];
55
}
shared_block_t
;
56
#endif
57
58
#define SB_FULL 0
59
#define SB_EMPTY 1
60
61
int
sb_setup(
const
char
* key,
unsigned
int
size,
shared_block_t
* sb);
62
void
sb_finish(
shared_block_t
* sb);
63
void
sb_sem_init(
shared_block_t
* sb);
64
void
sb_sem_finish(
shared_block_t
* sb);
65
int
sb_sem_wait(
shared_block_t
* sb,
int
index);
66
int
sb_sem_try_wait(
shared_block_t
* sb,
int
index);
67
int
sb_sem_timed_wait(
shared_block_t
* sb,
int
index,
unsigned
int
ms);
68
void
sb_sem_signal(
shared_block_t
* sb,
int
index);
69
70
#endif
shared_block_t
Definition
ipc_smem.h:50
src
devices
ipc_smem.h
Generated by
1.9.8