This is the mail archive of the
ecos-discuss@sourceware.org
mailing list for the eCos project.
Thread scheduling problem
- From: "vasantha.rajan" <vasantha dot rajan at cranessoftware dot com>
- To: ecos-discuss at sources dot redhat dot com
- Cc: gary at mlbassoc dot com
- Date: Tue, 27 Dec 2005 18:19:06 +0530
- Subject: [ECOS] Thread scheduling problem
Hi Gary,
Thanks for your reply,but still i cant get the problem.
I will give two set of programs below.
program 1:
void cyg_user_start()
{
cyg_thread_create(10, &counter_thread, 0 ,"counter_thread", stack, STACKSIZE,
&handle, &thread);
cyg_thread_resume(handle);
printf("End of start");
}
// The thread resumed
void counter_thread(cyg_addrword_t data)
{
printf("inside counter thread\n");
cyg_thread_delay(10);
printf("delay completed\n");
}
program 2:
void cyg_user_start()
{
cyg_semaphore_init(&sem,val);
cyg_thread_create(10, &counter_thread, 0 ,"counter_thread", stack, STACKSIZE,
&handle, &thread);
cyg_thread_resume(handle);
cyg_semaphore_wait(&sem); // Initial value of val is 0
printf("End of start");
}
// The thread resumed
void counter_thread(cyg_addrword_t data)
{
printf("inside counter thread\n");
cyg_thread_delay(10);
printf("delay completed\n");
}
when i run program 1:The thread is resumed after scheduler starts and the
thread waits for the stipulated amount of time and again resumes and prints
the statement "delay completed".
when i run program 2:The thread is resumed before cyg_user_start() ends
ie,before the scheduler starts(I guess...) and it waits infinitely thereonly
and the statement "delay completed" is not printed.(I am not posting the
semaphore... I think that wont be a problem...)
So my question is
1.What is the difference between the two codes??
2.Does scheduler comes into picture in both the codes??
3.In code 2 why does the program waits infinitely?(It means the scheduler
doesnt have control over that particular thread)
sorry for a lengthy mail....
Thanks
Regards
Vasanth
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss