This is Unofficial EPICS BASE Doxygen Site
osdSpin.c File Reference
#include <stdlib.h>
#include <intLib.h>
#include <logLib.h>
#include <taskLib.h>
#include "cantProceed.h"
#include "epicsSpin.h"
+ Include dependency graph for osdSpin.c:

Go to the source code of this file.

Classes

struct  epicsSpin
 

Macros

#define _VSB_CONFIG_FILE   <../lib/h/config/vsbConfig.h>
 

Typedefs

typedef struct epicsSpin epicsSpin
 

Functions

epicsSpinId epicsSpinCreate (void)
 
epicsSpinId epicsSpinMustCreate (void)
 
void epicsSpinDestroy (epicsSpinId spin)
 
void epicsSpinLock (epicsSpinId spin)
 
int epicsSpinTryLock (epicsSpinId spin)
 
void epicsSpinUnlock (epicsSpinId spin)
 

Macro Definition Documentation

#define _VSB_CONFIG_FILE   <../lib/h/config/vsbConfig.h>

Definition at line 32 of file osdSpin.c.

Typedef Documentation

typedef struct epicsSpin epicsSpin

Function Documentation

epicsSpinId epicsSpinCreate ( void  )

Definition at line 47 of file osdSpin.c.

47  {
48  return calloc(1, sizeof(epicsSpin));
49 }
void epicsSpinDestroy ( epicsSpinId  spin)

Definition at line 59 of file osdSpin.c.

59  {
60  free(spin);
61 }
void epicsSpinLock ( epicsSpinId  spin)

Definition at line 63 of file osdSpin.c.

63  {
64  int key = intLock();
65 
66  if (!intContext())
67  taskLock();
68  if (spin->locked) {
69  intUnlock(key);
70  if (!intContext()) {
71  taskUnlock();
72  logMsg("epicsSpinLock(%p): Deadlock.\n",
73  (int) spin, 0, 0, 0, 0, 0);
74  cantProceed("Recursive lock, missed unlock or block when locked.");
75  }
76  else {
77  logMsg("epicsSpinLock(%p): Deadlock in ISR.\n"
78  "Recursive lock, missed unlock or block when locked.\n",
79  (int) spin, 0, 0, 0, 0, 0);
80  }
81  return;
82  }
83  spin->key = key;
84  spin->locked = 1;
85 }
int key
Definition: osdSpin.c:43
unsigned int locked
Definition: osdSpin.c:39
LIBCOM_API void cantProceed(const char *msg,...)
Definition: cantProceed.c:54
epicsSpinId epicsSpinMustCreate ( void  )

Definition at line 51 of file osdSpin.c.

52 {
54  if (!ret)
55  cantProceed("epicsSpinMustCreate: epicsSpinCreate failed.");
56  return ret;
57 }
LIBCOM_API void cantProceed(const char *msg,...)
Definition: cantProceed.c:54
epicsSpinId epicsSpinCreate(void)
Definition: osdSpin.c:28
int epicsSpinTryLock ( epicsSpinId  spin)

Definition at line 87 of file osdSpin.c.

87  {
88  int key = intLock();
89 
90  if (!intContext())
91  taskLock();
92  if (spin->locked) {
93  intUnlock(key);
94  if (!intContext())
95  taskUnlock();
96  return 1;
97  }
98  spin->key = key;
99  spin->locked = 1;
100  return 0;
101 }
int key
Definition: osdSpin.c:43
unsigned int locked
Definition: osdSpin.c:39
void epicsSpinUnlock ( epicsSpinId  spin)

Definition at line 103 of file osdSpin.c.

103  {
104  int key = spin->key;
105 
106  if (!spin->locked) {
107  logMsg("epicsSpinUnlock(%p): not locked\n",
108  (int) spin, 0, 0, 0, 0, 0);
109  return;
110  }
111  spin->key = spin->locked = 0;
112  intUnlock(key);
113  if (!intContext())
114  taskUnlock();
115 }
int key
Definition: osdSpin.c:43
unsigned int locked
Definition: osdSpin.c:39