Jump to content
Sign in to follow this  
Jamie

Understanding Syssignalsemaphoreisr()

Recommended Posts

I'm drafting a blog/sample for Novo.

 

Can you confirm that my following understanding of SysSignalSemaphoreIsr is correct?

 

I believe the following code to be broken:

void interrupt(void)
{
if ( /* int1 flag test */ )
{
	SysSignalSemaphoreIsr(hSem1);
	/* clear int1 flag */
}
if ( /* int2 flag test */ )
{
	SysSignalSemaphoreIsr(hSem2);
	/* clear int2 flag */
}
}

Should int1 and int2 flags both be set, "SysSignalSemaphoreIsr(hSem1);" would effectively be ignored.

 

If my understanding is correct, is there a trivial workaround?

Share this post


Link to post
Share on other sites
I'm drafting a blog/sample for Novo.

 

Can you confirm that my following understanding of SysSignalSemaphoreIsr is correct?

 

I believe the following code to be broken:

void interrupt(void)
{
if ( /* int1 flag test */ )
{
	SysSignalSemaphoreIsr(hSem1);
	/* clear int1 flag */
}
if ( /* int2 flag test */ )
{
	SysSignalSemaphoreIsr(hSem2);
	/* clear int2 flag */
}
}

Should int1 and int2 flags both be set, "SysSignalSemaphoreIsr(hSem1);" would effectively be ignored.

 

If my understanding is correct, is there a trivial workaround?

Both calls to SysSignalSemaphoreIsr(); are significant as they affect different semaphores.

Even if they both operated on the same semaphore they would still be significant because the semaphores are of a counting type, so two calls to SysSignalSemaphoreIsr(hSem1); would cause the hSem1 value to be increased by 2.

 

Regards

Dave

Share this post


Link to post
Share on other sites
I'm drafting a blog/sample for Novo.

 

Can you confirm that my following understanding of SysSignalSemaphoreIsr is correct?

 

I believe the following code to be broken:

void interrupt(void)
{
if ( /* int1 flag test */ )
{
	SysSignalSemaphoreIsr(hSem1);
	/* clear int1 flag */
}
if ( /* int2 flag test */ )
{
	SysSignalSemaphoreIsr(hSem2);
	/* clear int2 flag */
}
}

Should int1 and int2 flags both be set, "SysSignalSemaphoreIsr(hSem1);" would effectively be ignored.

 

If my understanding is correct, is there a trivial workaround?

Both calls to SysSignalSemaphoreIsr(); are significant as they affect different semaphores.

Even if they both operated on the same semaphore they would still be significant because the semaphores are of a counting type, so two calls to SysSignalSemaphoreIsr(hSem1); would cause the hSem1 value to be increased by 2.

 

Regards

Dave

Hi Dave,

I'm trying to understand the significance of the following in the documentation:

 

This function signals a semaphore from within an interrupt service routine (ISR), that is it

increases the semaphore value by 1. Because this function is called within an ISR, the event

wakeup action iwill not be completed until the next task scheduler yield occurs. This is

performed by the semaphore signaling being put in a an ISR command queue. The

command queue only has a length of 1, so if more than one event object is signaled before

the next scheduler yield occurs, then task wakeup will be missed, leaving the task in the

event queue.

 

This would suggest that if the two semaphores in above example were being waited on by two different threads, then only one of them would be moved to the wait queue? Or has the behavior chanced since this description was written?

Share this post


Link to post
Share on other sites
Hi Dave,

I'm trying to understand the significance of the following in the documentation:

 

This function signals a semaphore from within an interrupt service routine (ISR), that is it

increases the semaphore value by 1. Because this function is called within an ISR, the event

wakeup action iwill not be completed until the next task scheduler yield occurs. This is

performed by the semaphore signaling being put in a an ISR command queue. The

command queue only has a length of 1, so if more than one event object is signaled before

the next scheduler yield occurs, then task wakeup will be missed, leaving the task in the

event queue.

 

This would suggest that if the two semaphores in above example were being waited on by two different threads, then only one of them would be moved to the wait queue? Or has the behavior chanced since this description was written?

Looking at the source code its looks like the documentation is out of date. I remember once trying to implement at ultra lightweight SysSignalSemaphoreIsr function, but this caused too many other issues.

 

Regards

Dave

Share this post


Link to post
Share on other sites
Hi Dave,

I'm trying to understand the significance of the following in the documentation:

 

This function signals a semaphore from within an interrupt service routine (ISR), that is it

increases the semaphore value by 1. Because this function is called within an ISR, the event

wakeup action iwill not be completed until the next task scheduler yield occurs. This is

performed by the semaphore signaling being put in a an ISR command queue. The

command queue only has a length of 1, so if more than one event object is signaled before

the next scheduler yield occurs, then task wakeup will be missed, leaving the task in the

event queue.

 

This would suggest that if the two semaphores in above example were being waited on by two different threads, then only one of them would be moved to the wait queue? Or has the behavior chanced since this description was written?

Looking at the source code its looks like the documentation is out of date. I remember once trying to implement at ultra lightweight SysSignalSemaphoreIsr function, but this caused too many other issues.

 

Regards

Dave

 

This is good to know, thanks Dave!

Share this post


Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...