lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [lwip-users] sys_sem_new initial conditions


From: Goldschmidt Simon
Subject: RE: [lwip-users] sys_sem_new initial conditions
Date: Wed, 28 Nov 2007 13:38:53 +0100

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: address@hidden [mailto:address@hidden Im Auftrag von Muhamad Ikhwan Ismail
Gesendet: Mittwoch, 28. November 2007 13:31
An: address@hidden
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

reply via email to

[Prev in Thread] Current Thread [Next in Thread]