Do not try to make the scheduler preemptive.
Test your program with a pair of application threads based on the following pseudocode:
thread1: semaphore d is initially 0 repeat at( now + 10 seconds, d ) wait( d ) output control g to standard error relinquish forever thread2: repeat relinquish read a line of input from standard input relinquish echo the line to standard output foreverUse the standard C library I/O routines. Do not try to fix any anomolous behavior of the result