Pages: [1]
|
|
|
Author
|
Topic: threads questions (Read 1666 times)
|
Rib Rdb
Frungy champion
Offline
Gender:
Posts: 85
|
Am I correct in understanding that the threads use cooperative multitasking? Is there a list of the different tasks/threads and what they do? Do the tasks use pointers to stack variables (I'm wondering if it would be possible to use something like what's described in the may or november 1995 Dr. Dobb's Journal for the task switching)
|
|
|
Logged
|
|
|
|
Michael Martin
Core Team
*Smell* controller
Offline
Posts: 387
|
No. The *original* code used cooperative multitasking, but SDL threads are pre-emptive or (on OS 9) nonexistent.
We add a little bit of thread-local heap data (see /doc/devel/threads) but the raw mechanics of thread implementation are closest to a kernel-threads implementation of pthreads. (This matches what Win32 and Linux do.) BSD is messier; see below.
We just made "TaskSwitch" be "sleep for a millisecond", which generally signals that you're willing to give up your timeslice if anyone's waiting.
We've had to code almost as if we were using cooperative multitasking, though, because BSD's thread model is entirely in user space, and there have been cases of deadlocks that appear only in BSD that I believe have to do with the priority inversion problem (e.g., the thread is waiting on another one, but that other one never gets a chance to run because the waiting thread blocks the entire process.)
I say "almost as if" because I don't have the slightest clue whether there are sufficient TaskSwitch()es to make it work under cooperative threading conditions.
But if there are, then we could make this run under OS 9 too.
An ongoing long-term project is to diminish the number of threads the program uses, possibly to collapse them entirely. There are some high-level decisions about that that still need to be made, though.
|
|
|
Logged
|
|
|
|
Rib Rdb
Frungy champion
Offline
Gender:
Posts: 85
|
I just got word that eCos will run on an unmodified GBA, so I guess I'll try to get that working. It supports preempting, and is probably going to be a lot better than anything I could write. The recursive mutexes will have to be emulated though. Are these only used by the graphics code? If so I'll probably wait on them until I have a better idea of how the graphics will work to see if the recursive mutexes will still be necessary on the GBA.
|
|
|
Logged
|
|
|
|
Michael Martin
Core Team
*Smell* controller
Offline
Posts: 387
|
The recursive mutexes are emulated already (in terms of normal mutexes). The graphics code and the audio code both use them.
|
|
|
Logged
|
|
|
|
Pages: [1]
|
|
|
|
|