Re: Multitasking in Mac OS Gets 100% CPU

new topic     » goto parent     » topic index » view thread      » older message » newer message

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 
new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu