Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Functions
semaphore.c File Reference
#include <linux/compiler.h>
#include <linux/kernel.h>
#include <linux/export.h>
#include <linux/sched.h>
#include <linux/semaphore.h>
#include <linux/spinlock.h>
#include <linux/ftrace.h>

Go to the source code of this file.

Data Structures

struct  semaphore_waiter
 

Functions

void down (struct semaphore *sem)
 
 EXPORT_SYMBOL (down)
 
int down_interruptible (struct semaphore *sem)
 
 EXPORT_SYMBOL (down_interruptible)
 
int down_killable (struct semaphore *sem)
 
 EXPORT_SYMBOL (down_killable)
 
int down_trylock (struct semaphore *sem)
 
 EXPORT_SYMBOL (down_trylock)
 
int down_timeout (struct semaphore *sem, long jiffies)
 
 EXPORT_SYMBOL (down_timeout)
 
void up (struct semaphore *sem)
 
 EXPORT_SYMBOL (up)
 

Function Documentation

void down ( struct semaphore sem)

down - acquire the semaphore : the semaphore to be acquired

Acquires the semaphore. If no more tasks are allowed to acquire the semaphore, calling this function will put the task to sleep until the semaphore is released.

Use of this function is deprecated, please use down_interruptible() or down_killable() instead.

Definition at line 53 of file semaphore.c.

int down_interruptible ( struct semaphore sem)

down_interruptible - acquire the semaphore unless interrupted : the semaphore to be acquired

Attempts to acquire the semaphore. If no more tasks are allowed to acquire the semaphore, calling this function will put the task to sleep. If the sleep is interrupted by a signal, this function will return -EINTR. If the semaphore is successfully acquired, this function returns 0.

Definition at line 75 of file semaphore.c.

int down_killable ( struct semaphore sem)

down_killable - acquire the semaphore unless killed : the semaphore to be acquired

Attempts to acquire the semaphore. If no more tasks are allowed to acquire the semaphore, calling this function will put the task to sleep. If the sleep is interrupted by a fatal signal, this function will return -EINTR. If the semaphore is successfully acquired, this function returns 0.

Definition at line 101 of file semaphore.c.

int down_timeout ( struct semaphore sem,
long  jiffies 
)

down_timeout - acquire the semaphore within a specified time : the semaphore to be acquired : how long to wait before failing

Attempts to acquire the semaphore. If no more tasks are allowed to acquire the semaphore, calling this function will put the task to sleep. If the semaphore is not released within the specified number of jiffies, this function returns -ETIME. It returns 0 if the semaphore was acquired.

Definition at line 155 of file semaphore.c.

int down_trylock ( struct semaphore sem)

down_trylock - try to acquire the semaphore, without waiting : the semaphore to be acquired

Try to acquire the semaphore atomically. Returns 0 if the semaphore has been acquired successfully or 1 if it it cannot be acquired.

NOTE: This return value is inverted from both spin_trylock and mutex_trylock! Be careful about this when converting code.

Unlike mutex_trylock, this function can be used from interrupt context, and the semaphore can be released by any task or interrupt.

Definition at line 130 of file semaphore.c.

EXPORT_SYMBOL ( down  )
EXPORT_SYMBOL ( down_interruptible  )
EXPORT_SYMBOL ( down_killable  )
EXPORT_SYMBOL ( down_trylock  )
EXPORT_SYMBOL ( down_timeout  )
EXPORT_SYMBOL ( up  )
void up ( struct semaphore sem)

up - release the semaphore : the semaphore to release

Release the semaphore. Unlike mutexes, up() may be called from any context and even by tasks which have never called down().

Definition at line 178 of file semaphore.c.