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.

No comments:

Post a Comment