Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Register Log in

how to implement semaphore?

Status
Not open for further replies.

ahgu

Full Member level 3
Joined
Jun 19, 2001
Messages
172
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,298
Activity points
1,552
how to implement simple semaphore?

and task threading control?

anywhere I can read on?

thanks
ahgu
 

GrandAlf

Advanced Member level 2
Joined
Mar 9, 2002
Messages
520
Helped
47
Reputation
92
Reaction score
6
Trophy points
1,298
Location
UK
Activity points
4,730
I assume that you are using a RTOS?. These usually have built in communication between tasks. Of couse you can always use public bit variables to flag between tasks. Can you be more specific on what you are trying to do.
 

tlp71@hotmail.com

Full Member level 4
Joined
May 14, 2002
Messages
220
Helped
6
Reputation
12
Reaction score
2
Trophy points
1,298
Activity points
1,595
depending for your O.S there is primitive that implement semaphore.
 

radu

Member level 2
Joined
May 30, 2001
Messages
51
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Location
Baenre compound, MENZOBERRANZAN
Activity points
398
reply no1 is good, you could have binary semaphore (mutex between 2 threads) or a counting semaphore with atomic WAIT(S) and SIGNAL(S). Depending on what you init the S with you can have that many threads accessing the critical section. WAIT(S) decrements S (and lets x threads through, x=current S) and SIGNAL(s) increments.
However reply2 is also good. there are generic wait(S) and signal(S) depending on what you use for coding.
 

tahiti

Junior Member level 2
Joined
Jan 23, 2003
Messages
24
Helped
2
Reputation
4
Reaction score
1
Trophy points
1,283
Activity points
262
If you are good in java, read :
lee : concurrent programming in java,
it's a bit heavy for reading, but it's very
good. you will understand all synchronization
issues (even quite advance ones)

tahiti
 

neuralc

Full Member level 4
Joined
Nov 6, 2001
Messages
236
Helped
9
Reputation
18
Reaction score
3
Trophy points
1,298
Activity points
2,202
Hi,

I think the answer depends on the platform that you will use for the semaphor.

If it is an embebed system, you must think in an RTOS, depending on the micro that you will use, you can find many RTOS framworks (ex. Slavo for PIC, ...)


If you whan to use a PC or something simillar (a PC/104, a Java enabled processor, ...) you can use Languages such Java that disponibilize threads that can be sincronized, and you can use the system timer events.

Hope helps,

NeuralC
 

Status
Not open for further replies.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top