Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
I'm going to implement preemptive multitasking. Now if I disable interrupts while in kernel space (which makes my kernel non re-entrant, if I understand it well), then everything should be ok without synchronisation in te kernel (except synchronisation between processes, ofc)?
Hmm.. I understand the problem, and I understand it's something to avoid. I'll start learning more about synchronisation techniques.
A related question...
I have a log()-functions, which prints a text, character per character, to the bochs debug port. If an interrupt occured during the printing, and the interrupt used the log()-function itself, the output got mixed.
So I first thought: I'll protect the log-function with a spinlock. Ofcourse, this made my system hang, since at startup there is no timer interrupt (and there were no processes yet): the interrupt took over control, entered the spinlock, and couldn't leave it...
In my opinion, there is only one solution: disable interrupts while using log(). Is this good, or are there other synchronisation techniques for solviing this problem? Because later, when there is scheduling, a spinlock would be fine there?
turdus wrote:That's a BKL (Big Kernel Lock) or BGL (Big Giant Lock), which linux and bsds want to get rid off (with more or less success).
Turning interrupts off doesn't mean you have a BKL. The BKL is about protecting multiple CPUs from each other, whereas disabling interrupts protects a single CPU from, well, being interrupted.