Discussion Forum

task switching

Next Thread | Thread List | Previous Thread Start a Thread | Settings

DetailsMessage
Read-Only
Author
srilatha ayyannagari
Posted
10-May-2003 13:03 GMT
Toolset
None
New! task switching
Hi,

Does os_send_token() cause task switching?If so, my code given below is not working properly,task_1 is running continuously, and task_2 is never getting executed.
Please clarify my doubt.



void setup_serial_io (void)
{
SCON = 0x50; /* SCON: mode 1, 8-bit UART, enable rcvr */
TMOD |= 0x20; /* TMOD: timer 1, mode 2, 8-bit reload */
TH1 = 0xF0; /* TH1: reload value */
TR1 = 1; /* TR1: timer 1 run */
TI = 1; /* TI: set TI to send first char of UART */
}


void task_1 (void) _task_ TASK1 _priority_ 0
{
while (1)
{
// Delay for 200 ticks
os_wait (K_MBX + SEM_PRINTF, 255, 0); // Wait for printf
printf ("Task # %d\n", (int) os_running_task_id ());
os_send_token (SEM_PRINTF); // Done with printf
}
}


void task_2 (void) _task_ TASK2 _priority_ 0
{
while (1)
{

os_wait (K_MBX + SEM_PRINTF, 255, 0); // Wait for printf
printf ("Task # %d\n", (int) os_running_task_id ());
os_send_token (SEM_PRINTF); // Done with printf
}
}

regards,

srilatha.
Read-Only
Author
Jon Ward
Posted
10-May-2003 16:59 GMT
Toolset
None
New! RE: task switching
I don't believe it does. Take another look at the example in http://www.keil.com/support/docs/690.htm. There is a short delay before checking for the semaphore. I seem to recal that this was used in the example to allow other tasks to run.

Jon
Read-Only
Author
srilatha ayyannagari
Posted
29-May-2003 11:35 GMT
Toolset
None
New! RE: task switching
Thanx for your reply Jon.Is is correct that,
to switch from one task to another a short
delay must be there? or is there any other
way?


regards,
srilatha
Read-Only
Author
Jon Ward
Posted
29-May-2003 18:07 GMT
Toolset
None
New! RE: task switching
Yep - That's correct.

Jon

Next Thread | Thread List | Previous Thread Start a Thread | Settings