/*------------------------------------------------------------------------ * screate -- create and initialize a semaphore, returning its id *------------------------------------------------------------------------ */ SYSCALL screate(int count) { // added for PA0 tracing int start_time; int curridx = 15; if(syscall_trace_on == 1) { syscall_used[currpid] = 1; syscall_cnt[currpid][curridx]++; start_time = ctr1000; } STATWORD ps; int sem; disable(ps); if ( count<0 || (sem=newsem())==SYSERR ) { restore(ps); // added for PA0 tracing if(syscall_trace_on == 1) { syscall_time[currpid][curridx] += ctr1000 - start_time; } return(SYSERR); } semaph[sem].semcnt = count; /* sqhead and sqtail were initialized at system startup */ restore(ps); // added for PA0 tracing if(syscall_trace_on == 1) { syscall_time[currpid][curridx] += ctr1000 - start_time; } return(sem); }
/* initial count (>=0) */ SYSCALL Kscreate(int *ERRNO, int count) { int sem; disableps(); if (count < 0 || (sem=newsem()) == SYSERR) { enableps(); *ERRNO = ENOMEM; return SYSERR; } _semaph[sem].semcnt = count; enableps(); return sem; }
sid32 semcreate(int32 count) { intmask mask; sid32 sem; mask = disable(); if(count<0 || (sem=newsem())==SYSERR) { restore(mask); return SYSERR; } semtab[sem].secount = count; restore(mask); return sem; }
/*------------------------------------------------------------------------ * semcreate - Create a new semaphore and return the ID to the caller *------------------------------------------------------------------------ */ sid32 semcreate( int32 count /* Initial semaphore count */ ) { intmask mask; /* Saved interrupt mask */ sid32 sem; /* Semaphore ID to return */ mask = disable(); if (count < 0 || ((sem=newsem())==SYSERR)) { restore(mask); return SYSERR; } semtab[sem].scount = count; /* Initialize table entry */ restore(mask); return sem; }