This is the mail archive of the 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]
Other format: [Raw text]

blocking for n events

I have the following interesting synchronization problem.
I am triggering a random number of transaction. Only after the last one I will
know how many I actually triggered. Then I need to wait for all of them to complete.

In my imagination, I have a semaphore that I can decrease by n, and then wake up
when it was posted n times and so is back to 0.

However, eCos semaphores don't work that way, and maybe they seldomly do. So, do
you have a suggestion what to do instead? As I said, I don't have the number of
transcations before, so I can't just set a variable and decrease it from the
callback, and then trigger an event flag.
What I could do is to wait for the semaphore in a for() loop, but I want to
avoid the overhead of task switches.


while ( ! transaction->isLastTransaction);
cyg_semaphore_wait_multiple(&my_sema, transaction_count);


void TransactionCallback()

Before posting, please read the FAQ:
and search the list archive:

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