![]() Some semaphore functions are specifically. * * Use of this function is deprecated, please use down_interruptible() or * down_killable() instead. Unnamed semaphores provide multiple accesses to a resource within a single process or between related processes. Semaphore in C semopen, Opens/creates a named semaphore for use by a process semwait, lock a semaphore sempost, unlock a semaphore semclose, Deallocates. If no more tasks are allowed to acquire the * semaphore, calling this function will put the task to sleep until the * semaphore is released. */ #include #include #include #include #include #include #include #include #include static noinline void _down ( struct semaphore * sem ) static noinline int _down_interruptible ( struct semaphore * sem ) static noinline int _down_killable ( struct semaphore * sem ) static noinline int _down_timeout ( struct semaphore * sem, long timeout ) static noinline void _up ( struct semaphore * sem ) /** * down - acquire the semaphore * the semaphore to be acquired * * Acquires the semaphore. If it's zero, there may be tasks waiting on the wait_list. For both operations the execution sequences from A to B or from A to C must be indivisible for P and V operations performed on the same semaphore. * * The ->count variable represents how many more tasks can acquire this * semaphore. It turns out various * parts of the kernel expect to be able to use down() on a semaphore in * interrupt context when they know it will succeed, so we have to use * irqsave variants for down(), down_interruptible() and down_killable() * too. Semaphores are a synchronization mechanism used to coordinate the activities of multiple processes in a computer system. * down_trylock() and up() can be called from interrupt context, so we * have to disable interrupts when taking the lock. ![]() ![]() */ /* * Some notes on the implementation: * * The spinlock controls access to the other members of the semaphore. * See mutex.c for single-acquisition sleeping locks which enforce * rules which allow code to be debugged more easily. * A counting semaphore may be acquired 'n' times before sleeping. SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2008 Intel Corporation * Author: Matthew Wilcox * * This file implements counting semaphores.
0 Comments
Leave a Reply. |