LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   What are lightweight semaphores ? (https://www.linuxquestions.org/questions/programming-9/what-are-lightweight-semaphores-237492/)

indian 10-01-2004 08:00 AM

What are lightweight semaphores ?
 
Hi, I am working on semaphores but I am not able to understand that what are lightweight semaphores ?
Can some one tell me in detail that what are they or if some can give me a link ...Thanks in anticipation...regards...

cracauer 10-01-2004 09:56 AM

The term can have different meanings but usually it will mean it is a semaphore that does not trigger system calls when used.

The typical semaphores are prepared to work between different processes and hence of cause involve systemcalls. If you just synchronize inside one process you can do without.

You might get semaphores which are lightweight on the system calls but heavyweight when blocking (busy wait to avoid systemcalls for sleeping).

Typically the light semaphores will be used with userlevel threading (inside one OS process), then you can "emulate" sleeping by rescheduling a different thread, all without systemcalls.

indian 10-01-2004 11:53 AM

hi cracauer,
Can u be more specific.I understood most of what u have said but ..."just synchronize inside one process you can do without." what does this mean ...can u be more elaborate on this...Thanks a lot in anticipation ..regards...

cracauer 10-01-2004 11:59 AM

If you have pure userlevel threads that run inside one operating system process, then you can use sempahores that will work without any systemcalls.

You can still have semephores with no systemcalls if you have multiple OS-level threads, but then you need a busy-wait which will usually not be worth it.

indian 10-01-2004 12:06 PM

ok got it ..But for this I have to define my own structures of semaphore and probably own functions as well...isn't it...Thanks for showing interest by the way....

cracauer 10-01-2004 12:51 PM

Well, if they are not supplied with your OS then you would have to build them on your own.

indian 10-02-2004 07:48 AM

One more thing...I want to make light weight (in both memory and performance...) semaphores .Any suggestions how can I do that.Can I reduce the memory usage by defining my own semaphores ?
THanks in anticipation..


All times are GMT -5. The time now is 12:33 AM.