sba1 / adtools

Experimental GNU toolchain for AmigaOS
31 stars 18 forks source link

GThreads: Rewrite __gthread_once() #115

Open sba1 opened 2 years ago

sba1 commented 2 years ago

Since Reschedule() in OS4 does exactly nothing (and was deprecated in the lastest SDK, which may change in the future again), the intended behavour of the current __gthread_once implementation to quickly give up cpu is not met. Also, it is dangerous to poll in case the firstly entred thread A has a lower pri than a one B that enters later because the A preempted over B giving A no chance to continue. Thread A's priority may be risen to the one of B (in general, to the highest one), but this is rather difficult to achieve because we don't know what func does (it could mess around with task pri's as well).

The current way was always be meant as a temporay solution. It is now time to provide a correct solution possibly involving semphores.