Generic linked list structure for use with thread switching and semaphores