[ECOS] about timeslice and same priority thread switch.
yyl
ylyuan@csrd.org
Tue May 30 18:40:00 GMT 2000
ÃÂ
----- 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!
ÃÂ
ÃÂ
More information about the Ecos-discuss
mailing list