ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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...
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.
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...
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.
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....
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..
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.