URL
https://opencores.org/ocsvn/or1k_old/or1k_old/trunk
Subversion Repositories or1k_old
[/] [or1k_old/] [trunk/] [uclinux/] [uClinux-2.0.x/] [arch/] [i960/] [kernel/] [semaphore.c] - Rev 1782
Compare with Previous | Blame | View Log
/* * FILE: semaphore.c * AUTHOR: kma@cse.ogi.edu * DESCR: interrupt-safe i960 semaphore implementation; isn't ready for SMP */ #ident "$Id: semaphore.c,v 1.1.1.1 2001-09-10 07:43:56 simons Exp $" #include <asm/semaphore.h> #include <linux/sched.h> extern int __down_common(struct semaphore* sem, int intrflag) { long flags; int retval=0; save_flags(flags); cli(); if (--sem->count < 0) { if (intrflag) { interruptible_sleep_on(&sem->wait); if (current->signal & ~current->blocked) { retval = -1; } } else sleep_on(&sem->wait); } restore_flags(flags); return retval; } void down(struct semaphore * sem) { __down_common(sem, 0); } /* * This version waits in interruptible state so that the waiting * process can be killed. The down_failed_interruptible routine * returns negative for signalled and zero for semaphore acquired. */ extern int down_interruptible(struct semaphore * sem) { return __down_common(sem, 1); } /* * Primitives to spin on a lock. Needed only for SMP. */ extern void get_buzz_lock(int *lock_ptr) { #ifdef __SMP__ while (xchg(lock_ptr,1) != 0) ; #endif } extern void give_buzz_lock(int *lock_ptr) { #ifdef __SMP__ *lock_ptr = 0 ; #endif } /* * We wake people up only if the semaphore was negative (== somebody was * waiting on it). */ extern void up(struct semaphore * sem) { long flags; save_flags(flags); cli(); if (sem->count++ < 0) wake_up(&sem->wait); restore_flags(flags); }