This is the mail archive of the ecos-discuss@sourceware.cygnus.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Semaphores and context switch


I have 2 processes running at equal priority (MLQUEUE), and two semaphores
(sem1 & sem2) which are initially zero.

(1) Process 1 polls a semaphore (and some hardware) using
    cyg_semaphore_trywait(sem1).   Process 2 sets up a bunch of things,
    and then does cyg_semaphore_post(sem1), and cyg_semaphore_wait(sem2)

(2) Process 1 will eventually see the post, do some processing, and then
    do cyg_semaphore_post(sem2).

(3) Process 2 continues, and can use the data from process 1 if necessary.

Now, am I right in assuming that the context switch after
cyg_semaphore_wait(sem2) in (1) will occur at next tick instead
of exactly when cyg_semaphore_wait(sem2) is called?

The same goes for the cyg_semaphore_post(sem2) in (2), will the context
switch occur at the next tick or when the call is made?

Will this also apply to a cyg_thread_yield() ?

Q:
If this is so, how can I make the switch occur faster?
My current workaround would be increasing the tick rate.

Regards,
Daniel Kahlin

-- 
Daniel Kahlin                    <daniel.kahlin@netinsight.net>
Hardware System Designer         phone:  +46-8-685 04 00
Net Insight AB                   direct: +46-8-685 04 08
URL: http://www.netinsight.net   fax:    +46-8-685 04 20

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]