This is the mail archive of the ecos-discuss@sourceware.cygnus.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: about timeslice and same priority thread switch.


> yyl wrote:
> 
> Hi, after finished building the ecos1.3.1 on Redhat linux6.1(target is pc
> x86),I use gdb stub and the example twothreads.c to test.
> From the document and the code of kernel,I think the threads of same
> priority should switch by timeslice.But after comment the sentence in
> twothreads.c as followed:
>           cyg_thread_delay(200);
> I find no switch.Who can tell me why?

So you are saying that by changing the code to the following, it stops
working?

  printf("Beginning execution; thread data is %d\n", message);
 
/*  cyg_thread_delay(200); */
 
  for (;;) {
    delay = 200 + (rand() % 50);
 
    /* note: printf() must be protected by a
       call to cyg_mutex_lock() */
    cyg_mutex_lock(&cliblock); {
      printf("Thread %d: and now a delay of %d clock ticks\n",
             message, delay);
    }
    cyg_mutex_unlock(&cliblock);
    cyg_thread_delay(delay);
  }

Are you sure you didn't change anything in your configuration from the
default that you didn't mean to?

> I think the switch of thread
> invoked by dsr of real time clock interrupt.Is that right?

Yes. See Cyg_RealTimeClock::dsr() in kernel/VERSION/src/common/clock.cxx

Jifl
-- 
Red Hat, 35 Cambridge Place, Cambridge, UK. CB2 1NS  Tel: +44 (1223) 728762
"Plan to be spontaneous tomorrow."  ||  These opinions are all my own fault

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