This is the mail archive of the ecos-discuss@sources.redhat.com 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]

Re: clock stops during cyg_scheduler_lock()?



"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

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