From 3efe00a7d0c895c2bee68f4f6a0bc12cb1be3299 Mon Sep 17 00:00:00 2001 From: hadaq Date: Tue, 18 Aug 2009 15:47:37 +0000 Subject: [PATCH] iextern variable unsigned int trb_semlock = 0 inhibits semaphore-locking of FPGA . --- libtrbnet/trbcmd.c | 3 ++- libtrbnet/trbnet.c | 25 ++++++++++++++++--------- libtrbnet/trbnet.h | 4 +--- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/libtrbnet/trbcmd.c b/libtrbnet/trbcmd.c index f38a5e9..c9499f8 100644 --- a/libtrbnet/trbcmd.c +++ b/libtrbnet/trbcmd.c @@ -15,7 +15,7 @@ #define HEXMODE 0 #endif -#define VERSION_NUMBER "2.03 20090813" +#define VERSION_NUMBER "2.04 20090818" static int hexMode = HEXMODE; @@ -80,6 +80,7 @@ int main(int argc, char ** argv) trb_debug = 0; trb_lazy = 0; + trb_semlock = 1; /* Parse Arguments */ while ((opt = getopt(argc, argv, "+hf:n:d:DlHV")) != -1) { diff --git a/libtrbnet/trbnet.c b/libtrbnet/trbnet.c index ab9e7a1..3ab3ed2 100644 --- a/libtrbnet/trbnet.c +++ b/libtrbnet/trbnet.c @@ -140,6 +140,7 @@ static const key_t sem_key = 0x545242; unsigned int trb_debug = 0; unsigned int trb_lazy = 0; unsigned int trb_dma = 0; +unsigned int trb_semlock = 0; /* Declaration of a TRB-Package */ @@ -848,9 +849,11 @@ static int lockPorts() SEM_UNDO | IPC_NOWAIT /* sem_flg: remove sem if process gets killed */ } }; - + + if (trb_semlock == 0) return 0; + if (semop(semid, sops, 2) == -1) { - perror("TRB_SEMAPHORE"); + perror("TRB_SEMAPHORE lock"); trb_errno = TRB_SEMAPHORE; return -1; } @@ -868,12 +871,14 @@ static int unlockPorts() } }; + if (trb_semlock == 0) return 0; + if (semop(semid, sops, 1) == -1) { - perror("TRB_SEMAPHORE"); + perror("TRB_SEMAPHORE unlock"); trb_errno = TRB_SEMAPHORE; return -1; } - + return 0; } @@ -892,11 +897,13 @@ int init_ports() /* Set trberrno ?? */ return -1; } - - /* Get / Create semaphore */ - if ((semid = semget(sem_key, 1, IPC_CREAT | 0666)) == -1) { - trb_errno = TRB_SEMAPHORE; - return -1; + + /* Get / Create semaphore */ + if (trb_semlock > 0) { + if ((semid = semget(sem_key, 1, IPC_CREAT | 0666)) == -1) { + trb_errno = TRB_SEMAPHORE; + return -1; + } } return 0; diff --git a/libtrbnet/trbnet.h b/libtrbnet/trbnet.h index 7661dc9..effdf63 100644 --- a/libtrbnet/trbnet.h +++ b/libtrbnet/trbnet.h @@ -6,6 +6,7 @@ extern unsigned int trb_debug; extern unsigned int trb_lazy; extern unsigned int trb_dma; +extern unsigned int trb_semlock; /* ---------------------------------------------------------------------- */ @@ -220,9 +221,6 @@ int trb_fifo_flush(uint8_t channel); uint8_t info, uint8_t random, uint16_t number); - - - */ #endif -- 2.43.0