This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
Re: clock stops during cyg_scheduler_lock()?
- To: ecos-discuss at sourceware dot cygnus dot com
- Subject: Re: [ECOS] clock stops during cyg_scheduler_lock()?
- From: Hugo Tyson <hmt at redhat dot com>
- Date: 29 Nov 2000 19:54:57 +0000
- Newsgroups: cygnus.sourceware.ecos.d
- Organization: Red Hat UK
- References: <001401c05a3a$ad91f240$5210f080@ncl.ac.uk>
"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