In versions 4 and 5 of the C-library, approximately half the routines were reentrant. What is the current status? Will some functions ( such as the memory allocation routines ) never be reentrant? [Note: I know I can bracket non-reentrant routines with a semaphore.]
I'm sorry to say but for objects that are inherently global you must semaphore protect or disable task-switching/interrupts. The latter is not so appealing to me in a real-time system. Semaphores are nice because for things like a tty port (SBUF) you can give the display to one task and let it finish writing its coherent block of data to the tty. When this is complete, then another task pending on the tty semaphore will resume and write its coherent block of data to the tty and then release the semaphore. Not using a semaphore means you get text interspersed on the tty from both tasks, yuk. Pending on resources is just part of using a pre-emptive mulititasking kernel so, despite the ackwardness, semaphores are the way to do it properly, IMHO. - Mark