[ECOS] clock stops during cyg_scheduler_lock()?
Hugo Tyson
hmt@redhat.com
Wed Nov 29 12:00:00 GMT 2000
"David Geng" <deli.geng@ncl.ac.uk> writes:
> Hi, look at this program please.
>
> cyg_scheduler_lock();
>
> begin = clock();
>
> .. ...
>
> end = clock();
>
> printf("TIME:%f \n", (float)((float)(end-begin)/CLOCKS_PER_SEC));
>
> cyg_scheduler_unlock();
>
> After more than 10 second. It has the output:
>
> TIME:0.000000
>
> However, after I put the "cyg_scheduler_unlock();" before "end = clock();",
> it has:
>
> TIME:13.000000
>
> Is it normal?
Yes. The clock is "ticked" (incremented) in a DSR, in order safely to run
alarms, timeslicing, &c. With the scheduler locked, DSRs don't run, so the
clock does not tick.
Why are you locking the scheduler? It looks like it's a bit of a
sledgehammer for whatever synchronization you're trying to get. Perhaps
just set the priority of your thread high, or use a mutex instead?
HTH,
- Huge
More information about the Ecos-discuss
mailing list