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.


 
----- Original Message -----
From: Jonathan Larmour <jlarmour@redhat.co.uk>
To: yyl <ylyuan@csrd.org>
Cc: ecos <ecos-discuss@sourceware.cygnus.com>
Sent: Wednesday, May 31, 2000 5:47 AM
Subject: Re: [ECOS] 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?
  
     It working.I mean the threads execute in the turn which they resume,but not switch by timeslice,ie,only the first thread finished ,the second thread can start.The code I modified as followed(I comment two sentences):
     /*        cyg_thread_delay(200);  */
             for (i=0;i<=100;i + +) {
          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); */
 
 the result of the run:
          Entering twothreads' cyg_user_start() function
          Thread 0 and now a delay of 233 clock ticks
          ...
          ...
          Thread 0 and now a delay of 225 clock ticks
          Thread 1 and now a delay of 226 clock ticks
          ...
          ...
          Thread 1 and now a delay of 238 clock ticks
        
I think the result should be:
         
          Entering twothreads' cyg_user_start() function
          Thread 0 and now a delay of 233 clock ticks
          ...
          Thread 1 and now a delay of 226 clock ticks
          ...
          Thread 0 and now a delay of 233 clock tick
          ...
          Thread 1 and now a delay of 238 clock ticks
          ...
    
         
          I didn't change anything in the configuration from the default .

          Last I don't express clearly.I'm very sorry.
          Thank you very much!
 
 

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