STI_RET0_IF_ERR(!isbadsem(sem)); 5 STI_RET0_IF_ERR(semtable[sem].semstate == S_USED); 6 semtable[sem].semcount--; 7 if (semtable[sem].semcount < 0) { 8 tid_t tid = get_cur_thread_tid(); 9 STI_RET0_IF_ERR(change_state(tid, WAIT)); 10 thread *t = get_thread_ptr(tid); 11 *t->sid_ptr = sem; 12 STI_RET0_IF_ERR(enqueue_sem(tid, sem)); 13 putsn_serial("enqueue tid: ", tid); 14 thread_scheduler(); 15 } 16 io_sti(); 17 return 1; 18 } 15