Page 1 of 1

Uniprocessor

Posted: Fri Aug 18, 2006 4:44 am
by matthias
In a uni-processor environment do I need, mutexes, spinlocks, semaphores etc??

Posted: Fri Aug 18, 2006 8:39 am
by carbonBased
Spinlocks, no.

But if you're going to implement any form of multitasking you *will* need mutexes and semaphores (or an equivalent form of thread synchronization).

--Jeff

Posted: Sat Aug 19, 2006 2:20 pm
by matthias
Hmm, I've looked over osdever.net to find some good tutorials about semaphores, mutexes, but didn't really find something about these. Does anyone know a good tutorial, with which I mean a tutorial that has proven itself. Yes I can google it, but if I don't know if it is good I will lose valuable time, because soon I will start studying informatics, so I don't wish losing time on tutorials which are not good. I will need time for my study ;)

Posted: Sat Aug 19, 2006 3:51 pm
by carbonBased
There aren't many tutorials, that I've seen... I wrote my semaphores, mutexes and message queue's blindly. But they do work :)

I plan on writting a tutorial on these one of these days... maybe I'll write it fairly soon, as there appears to be a need for this sort of thing.

Effectively, you need to implement (potentially) new states to your task scheduler. You need a way to mark a task is waiting (ie, blocked on a mutex), and you need a way to bring that task back from waiting to ready once that mutex becomes available.

It would also be a good idea to create a function that, when called, voluntarily gives up control to another task (ie, allows a task to preempt itself, before its timeslice has elapsed).

If you'd like to look at some code, my latest OS contains all of these concepts and can be downloaded from www.neuraldk.org (look under software -> ndk ).

If you have any questions, feel free to post, and I'll see if I can explain, before I get this tut written.

--Jeff

Posted: Sat Aug 19, 2006 3:55 pm
by matthias
Such a tutorial I would like :P But I'll look up your source, thanks mate :D