I'm working on solving the Producer/Consumer problem through different methods. The one I'm currently working on involves my own implementation of a semaphore, paired with Peterson's solution to protect the semaphore's down() and up() function calls.
The problem is, I'm working in C, and the only way I can think of creating a semaphore would be to use a struct with function pointers for down() and up(). Is this the right idea?