Re: Multitasking in Mac OS Gets 100% CPU
- Posted by bryanso Nov 07, 2012
- 1407 views
This demonstrates task_delay has a bug. CPU remains at 100% even though the main loop and the thread both generously allow lots of delay:
include std/task.e integer t1_running procedure task1(sequence message) for i = 1 to 100 do printf(1, "task1 (%d) %s\n", {i, message}) task_delay(1) end for t1_running = 0 end procedure atom t1 = task_create(routine_id("task1"), {"Hello"}) task_schedule(t1, 10) t1_running = 1 while t1_running do if get_key() = 'q' then exit end if task_delay(5) end while