From: Joris v. d. S. <vd...@pu...> - 2001-01-04 23:14:37
|
Hi all, I have a non-preemptive MCS-51 version of ROSES up-and-running. To measure its speed, I have tried the following test program: #include "rtos.h" sbit red_led = P1^0 ; sbit green_led = P1^1 ; void blink_red_led(void) { while (1) { red_led = 0 ; rtos_task_sleep(0) ; red_led = 1 ; rtos_task_sleep(0) ; } } void blink_green_led(void) { while (1) { green_led = 0 ; rtos_task_sleep(0) ; green_led = 1 ; rtos_task_sleep(0) ; } } void main(void) { /* initialise the operating system */ rtos_init() ; /* create blink tasks */ rtos_task_create(1, blink_red_led, 100) ; rtos_task_create(2, blink_green_led, 100) ; /* reduce priority of main task */ rtos_task_priority(0, 110) ; } This results in two tasks blinking LEDs at maximum speed (since the main task has a lower priority and will never gain control again). Using an oscilloscope I see two square waves with a frequency of 615 Hz, 90 degrees out of phase. Since I used a 16 MHz. 80C32 board and it takes 4 task-switches per period of the square wave, it takes 542 cpu cycles to switch between tasks. This means that the latency of the operating system will be about half a millisecond. I am quite happy with this result, considering that most of the code is written in C to simplify porting the OS to other microcontroller families. Note that this test was compiled using the Keil compiler, perhaps the SDCC compiler generates even faster code. I will try to have a sneek-preview release ready by the end of this weekend. Regards, Joris |