-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Enable mutex functionality in nxsem #16194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -104,8 +104,16 @@ struct semholder_s | |
|
||
struct sem_s | ||
{ | ||
volatile int32_t semcount; /* >0 -> Num counts available */ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. since we always use macro access semcount/mholder, why not remove the union? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could do, I was thinking that it is safer / cleaner to do it like this. What would be a good name for combined holder/semcount? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Decided to keep it still, see the other comments regarding this |
||
/* <0 -> Num tasks waiting for semaphore */ | ||
union | ||
{ | ||
volatile int32_t semcount; /* >0 -> Num counts available */ | ||
/* <0 -> Num tasks waiting for semaphore */ | ||
volatile uint32_t mholder; /* == NXSEM_NO_MHOLDER -> mutex has no holder */ | ||
/* == NXSEM_RESET -> mutex has been reset */ | ||
/* Otherwise: */ | ||
/* bits[30:0]: TID of the current holder */ | ||
/* bit [31]: Mutex is blocking some task */ | ||
} val; | ||
|
||
/* If priority inheritance is enabled, then we have to keep track of which | ||
* tasks hold references to the semaphore. | ||
|
@@ -137,18 +145,18 @@ typedef struct sem_s sem_t; | |
/* semcount, flags, waitlist, hhead */ | ||
|
||
# define SEM_INITIALIZER(c) \ | ||
{(c), 0, SEM_WAITLIST_INITIALIZER, NULL} | ||
{{(c)}, 0, SEM_WAITLIST_INITIALIZER, NULL} | ||
# else | ||
/* semcount, flags, waitlist, holder[2] */ | ||
|
||
# define SEM_INITIALIZER(c) \ | ||
{(c), 0, SEM_WAITLIST_INITIALIZER, SEMHOLDER_INITIALIZER} | ||
{{(c)}, 0, SEM_WAITLIST_INITIALIZER, SEMHOLDER_INITIALIZER} | ||
# endif | ||
#else | ||
/* semcount, flags, waitlist */ | ||
|
||
# define SEM_INITIALIZER(c) \ | ||
{(c), 0, SEM_WAITLIST_INITIALIZER} | ||
{{(c)}, 0, SEM_WAITLIST_INITIALIZER} | ||
#endif | ||
|
||
#define SEM_WAITLIST(sem) (&((sem)->waitlist)) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not remove holder at line 52?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to left the cleanup of nxmutex for a next PR, this is already a big one.