2011-05-04

2011-05-04 - Delays and Sleep

So, I need to create some form of Timer_Sleep() function that works in a similar manner to my Timer_Delay().

Timer_Delay() currently spinlocks until the designated time ... functional, but not advisable.

Timer_Sleep() has to instead suspend the thread until the allotted time, then wake it up again.

2011-05-03

2011-05-03 - Semaphores

So my first foray into Semaphores didn't work first time.  I've implemented a test&set function, and I've created the GetSemaphore() and ReleaseSemaphore() functions which take a pointer to a semaphore and spinlock until it can be gained, and then to release it.  I tied this into the String_kprintf() function so that only one thread could be in the function at a time.  Instead of a proper lock, the system just locked when it first performed a printf, and presumably infinitely looped.

Ah ha!  In copying the code sample for the Intel implementation of test_and_set, I neglected to reverse the operands to the mov instructions, so the stack was being loaded with the values from the registers, not the other way around.  Why that would screw up the printing, I don't know.

2011-05-02

2011-05-02 - Multitasking on the Revo

Gotten the new Aspire Revo 3700 wired up in place of the thin client, nice little piece of kit with an integral hard drive amongst other things.  I'm ignoring the Linpus Linux for now and have it set to network boot, and it fired up the TFTP branch first time.

Been looking at the multitasking code using the Revo (not that it's any better in this regard than the T61) and trying to track down the problem.  Having spent ages sticking in various bits of debugging code and trying to make sense of the results, the solution ends up being stupidly simple ... the stack I was assigning to each thread was too small.  One stack would overwrite part of another, then cause it's Interrupt frame to be corrupt, crashing when that thread was next invoked.

With that 'fixed', the threads are ticking over happily.  It's currently running maybe 30 character generator threads with a quanta of 10ms to test it.  So far no problems except the video routines aren't multi-thread safe.