Hi M.,
 
Sounds like you could use an introduction about semaphores...
 
Semaphores in lwIP are counting: sys_sem_wait counts the semaphore
counter down by one and if it is zero when entering sys_sem_wait, it
waits until somebody else calls sys_sem_signal (which counts up by one)
so it can count down.
 
The 'initial conditions argument' passed to sys_sem_new sets the inital
value of the semaphore. E.g. when passing 0, the first call to
sys_sem_wait will really wait (unless sys_sem_signal is called first).
While when passing 1, the first call to sys_sem_wait will succeed
instantly and count the internal semaphore counter down to 0.
 
But this is really only a quick introduction, you should try to find a
book to read about that (e.g. "Modern Operating Systems" by Andrew S.
Tanenbaum).
 
Simon


________________________________

Von: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]
Im Auftrag von Muhamad Ikhwan Ismail
Gesendet: Mittwoch, 28. November 2007 13:31
An: [email protected]
Betreff: [lwip-users] sys_sem_new initial conditions


Hi..

I am porting lwip to SMX RTOS on PPC MPC852T from Freescale.
As I was comparing the 2 functions for creating a semaphore for both
lwip sys_arch.c and the one from smx
it hits me... what is meant with the initial conditions argument passed
to sys_sem_new on lwip, since
smx semaphores has by default FALSE as initial conditions and depending
on the Threshold and how many times it
as been signalled it will be set to TRUE which will be tested by the
task that needs that semaphore to be signalled.
I also noticed on some point in the code the sys_sem_new is called and
passed with value of 0 and 1.

I  really appreciate it if anyone can explain it.

Another short q, what is sys_sem_wait for ? 

Btw lwip is really a lifesaver for me, wanna say thanks a lot the lwip
developers :D

Thanks a bunch

M. Ikhwan

_______________________________________________
lwip-users mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/lwip-users

Reply via email to