UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old December 1st, 2003, 06:40 PM
VB_Oracle VB_Oracle is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 18 VB_Oracle User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Semaphores/Threads

Anyone one know where I can find an implementation of a semaphore using thread/pthread library in C for UNIX (I would like to use these semaphores in other programs)? Or, anyone have any ideas on how to implement one? I would really appreciate it. Thanks.

Reply With Quote
  #2  
Old December 1st, 2003, 11:10 PM
Perderabo Perderabo is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 121 Perderabo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 m 54 sec
Reputation Power: 5
I'm not sure that I understand the question, but I'll try to make a few remarks anyway....

A semaphore is thing that is usually implemented in the kernel. You need to be able to atomically test for zero and decrement. That can only be done in assembler. And you generally want the ability to sleep the process until the semaphore is non-zero and you really need the kernel for that. So a semaphore might be used in conjunction with pthreads. But implementing it out of pthreads does not make sense.

Threads are usually syncronized via mutexes. But they can use semaphores.

There are two styles of semaphores on unix. The first is the System V semaphores. "man semget" and "man semctl" should bring up some info about them.

A second style of semaphores comes from the Posix real-time extentions. They may not be on every version of Unix, especially the older versions. But "man sem_wait", "man sem_try", and "man sem_post" should bring up info about them if they exist.

Reply With Quote
  #3  
Old December 1st, 2003, 11:14 PM
VB_Oracle VB_Oracle is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 18 VB_Oracle User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I would like to implement the "wait" and "signal" operation of theoretical semaphores using the pthread library. Thanks.

Reply With Quote
  #4  
Old July 13th, 2004, 04:16 PM
spark_msk spark_msk is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 1 spark_msk User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thumbs up

So are you looking for implementation examples for pthreads........you should be able to find umpteen examples by doing a simple google search.......herez a link that I think would help u......

URL
Hope this helps

Reply With Quote
  #5  
Old July 17th, 2004, 10:17 AM
guggach guggach is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2004
Location: Middle Europa
Posts: 1,083 guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 Days 19 h 49 m 57 sec
Reputation Power: 9
http://www.kohala.com/start/
W. Richard Stevens' Home Page
is your teacher

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > Semaphores/Threads


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway