This is the mail archive of the ecos-discuss@sourceware.org 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


Hi-
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.

Heiko


do
{
	transaction=get_another_transaction();
	trigger_transaction(transaction);
	transaction_count++;
}
while ( ! transaction->isLastTransaction);
cyg_semaphore_wait_multiple(&my_sema, transaction_count);

...

void TransactionCallback()
{
	cyg_semaphore_post(&my_sema);
};

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss


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