* [ECOS] clock stops during cyg_scheduler_lock()?
@ 2000-11-29 11:30 David Geng
2000-11-29 12:00 ` Hugo Tyson
0 siblings, 1 reply; 2+ messages in thread
From: David Geng @ 2000-11-29 11:30 UTC (permalink / raw)
To: ecos-discuss
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?
//
// University of Newcastle upon Tyne
// Tel: +44 (0)191 222 6000 ext 5018
// http://www.students.ncl.ac.uk/deli.geng/
//
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [ECOS] clock stops during cyg_scheduler_lock()?
2000-11-29 11:30 [ECOS] clock stops during cyg_scheduler_lock()? David Geng
@ 2000-11-29 12:00 ` Hugo Tyson
0 siblings, 0 replies; 2+ messages in thread
From: Hugo Tyson @ 2000-11-29 12:00 UTC (permalink / raw)
To: ecos-discuss
"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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2000-11-29 12:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-11-29 11:30 [ECOS] clock stops during cyg_scheduler_lock()? David Geng
2000-11-29 12:00 ` Hugo Tyson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).