Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/hal/hal_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
*/

#define HAL_KEY 0x48414C32 /* key used to open HAL shared memory */
#define HAL_VER 0x00000011 /* version code */
#define HAL_VER 0x00000012 /* version code */
#define HAL_SIZE (2*256*4096)
#define HAL_PSEUDO_COMP_PREFIX "__" /* prefix to identify a pseudo component */

Expand Down
26 changes: 26 additions & 0 deletions src/rtapi/rtapi_mutex.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,17 @@

typedef unsigned long rtapi_mutex_t;

/*
* The normal mutex functions use zero (0) as the unlocked state and one (1) as
* the locked state.
* The mutex functions with the _rd suffix are `reverse default' versions, in
* which the locked state is represented by zero (0) and the unlocked state by
* one (1).
*
* A shared memory recursive mutex must be initialized in the locked state.
* This maps cleanly to reverse default when the shared memory is created,
* which defaults to zero and thus a locked mutex.
*/

/**
* @brief Releases the mutex.
Expand All @@ -52,6 +63,9 @@ typedef unsigned long rtapi_mutex_t;
static __inline__ void rtapi_mutex_give(unsigned long *mutex) {
test_and_clear_bit(0, mutex);
}
static __inline__ void rtapi_mutex_give_rd(unsigned long *mutex) {
test_and_set_bit(0, mutex);
}
/**
* @brief Non-blocking attempt to get the mutex.
*
Expand All @@ -67,6 +81,9 @@ typedef unsigned long rtapi_mutex_t;
static __inline__ int rtapi_mutex_try(unsigned long *mutex) {
return test_and_set_bit(0, mutex);
}
static __inline__ int rtapi_mutex_try_rd(unsigned long *mutex) {
return !test_and_clear_bit(0, mutex);
}

/**
* @brief Blocking attempt to gGet the mutex.
Expand All @@ -85,6 +102,15 @@ typedef unsigned long rtapi_mutex_t;
#endif
}
}
static __inline__ void rtapi_mutex_get_rd(unsigned long *mutex) {
while (!test_and_clear_bit(0, mutex)) {
#if defined(__KERNEL__)
schedule();
#else
sched_yield();
#endif
}
}


#endif
5 changes: 5 additions & 0 deletions src/rtapi/rtapi_stdint.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,10 @@ typedef uintptr_t rtapi_uintptr_t;
typedef double rtapi_real;
typedef rtapi_s64 rtapi_sint;
typedef rtapi_u64 rtapi_uint;
typedef rtapi_intptr_t rtapi_port;

#define RTAPI_SINT_MAX RTAPI_INT64_MAX
#define RTAPI_SINT_MIN RTAPI_INT64_MIN
#define RTAPI_UINT_MAX RTAPI_UINT64_MAX

#endif
Loading