+
+void Threads_Sleep(void)
+{
+ pause();
+}
+
+void Threads_Yield(void)
+{
+// yield();
+}
+
+int Threads_WakeTID(tTID TID)
+{
+ tThread *thread;
+ thread = Threads_GetThread(TID);
+ if( !thread ) return -1;
+ kill( thread->KernelTID, SIGUSR1 );
+ return 0;
+}
+
+void Mutex_Acquire(tMutex *Mutex)
+{
+ if(!Mutex->Protector.IsValid) {
+ pthread_mutex_init( &Mutex->Protector.Mutex, NULL );
+ Mutex->Protector.IsValid = 1;
+ }
+ pthread_mutex_lock( &Mutex->Protector.Mutex );
+}
+
+void Mutex_Release(tMutex *Mutex)
+{
+ pthread_mutex_unlock( &Mutex->Protector.Mutex );
+}
+
+#if 0
+void Threads_Sleep()
+{
+ gpCurrentThread->State = 3;
+ if( setjmp(&gpCurrentThread->CurState) == 0 ) {
+ // Return to user wait
+ // Hmm... maybe I should have a "kernel" thread for every "user" thread
+ }
+ else {
+ // Just woken up, return
+ return ;
+ }
+}
+
+int SaveState(tState *To)
+{
+ Uint ip;
+ __asm__ __volatile__(
+ "call 1f;\n\t"
+ "1f:\n\t"
+ "pop %%eax"
+ : "=a" (ip)
+ : );
+ // If we just returned
+ if(!ip) return 1;
+
+ To->IP = ip;
+ __asm__ __volatile__ ("mov %%esp, %1" : "=r"(To->SP));
+ __asm__ __volatile__ ("mov %%ebp, %1" : "=r"(To->BP));
+}
+#endif
+