This is the mail archive of the
ecos-discuss@sourceware.cygnus.com
mailing list for the eCos project.
Re: about timeslice and same priority thread switch.
- To: "Jonathan Larmour" <jlarmour at redhat dot co dot uk>
- Subject: Re: [ECOS] about timeslice and same priority thread switch.
- From: "yyl" <ylyuan at csrd dot org>
- Date: Wed, 31 May 2000 09:30:46 +0800
- Cc: "ecos" <ecos-discuss at sourceware dot cygnus dot com>
- References: <002001bfc9d5$a9f843a0$2901a8c0@21> <393436D7.104D0E0B@redhat.co.uk>
----- Original Message -----
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!