LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 10-01-2004, 08:00 AM   #1
indian
Member
 
Registered: Aug 2004
Posts: 137

Rep: Reputation: 15
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...
 
Old 10-01-2004, 09:56 AM   #2
cracauer
Member
 
Registered: Jul 2004
Location: Boston, MA, USA
Distribution: FreeBSD, Debian/AMD64, Ubuntu/i386
Posts: 59

Rep: Reputation: 15
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.
 
Old 10-01-2004, 11:53 AM   #3
indian
Member
 
Registered: Aug 2004
Posts: 137

Original Poster
Rep: Reputation: 15
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...
 
Old 10-01-2004, 11:59 AM   #4
cracauer
Member
 
Registered: Jul 2004
Location: Boston, MA, USA
Distribution: FreeBSD, Debian/AMD64, Ubuntu/i386
Posts: 59

Rep: Reputation: 15
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.
 
Old 10-01-2004, 12:06 PM   #5
indian
Member
 
Registered: Aug 2004
Posts: 137

Original Poster
Rep: Reputation: 15
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....
 
Old 10-01-2004, 12:51 PM   #6
cracauer
Member
 
Registered: Jul 2004
Location: Boston, MA, USA
Distribution: FreeBSD, Debian/AMD64, Ubuntu/i386
Posts: 59

Rep: Reputation: 15
Well, if they are not supplied with your OS then you would have to build them on your own.
 
Old 10-02-2004, 07:48 AM   #7
indian
Member
 
Registered: Aug 2004
Posts: 137

Original Poster
Rep: Reputation: 15
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..
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
semaphores and threads aenasir Programming 0 10-06-2004 09:07 PM
questions on semaphores feetyouwell Programming 3 10-03-2004 09:55 PM
What is Semaphores? imsajjadali Red Hat 3 04-23-2004 01:26 AM
Semaphores help mojozoox Programming 1 01-07-2004 08:41 AM
semaphores charles_sjc Linux - Software 2 12-06-2003 12:15 AM


All times are GMT -5. The time now is 11:54 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration