Linux Audio

Check our new training course

Loading...
#ifndef __LINUX_SMPLOCK_H
#define __LINUX_SMPLOCK_H

#include <linux/config.h>
#include <linux/sched.h>
#include <linux/spinlock.h>

#if CONFIG_SMP || CONFIG_PREEMPT

extern spinlock_t kernel_flag;

#define kernel_locked()		(current->lock_depth >= 0)

#define get_kernel_lock()	spin_lock(&kernel_flag)
#define put_kernel_lock()	spin_unlock(&kernel_flag)

/*
 * Release global kernel lock.
 */
static inline void release_kernel_lock(struct task_struct *task)
{
	if (unlikely(task->lock_depth >= 0))
		put_kernel_lock();
}

/*
 * Re-acquire the kernel lock
 */
static inline void reacquire_kernel_lock(struct task_struct *task)
{
	if (unlikely(task->lock_depth >= 0))
		get_kernel_lock();
}

/*
 * Getting the big kernel lock.
 *
 * This cannot happen asynchronously,
 * so we only need to worry about other
 * CPU's.
 */
static inline void lock_kernel(void)
{
	int depth = current->lock_depth+1;
	if (likely(!depth))
		get_kernel_lock();
	current->lock_depth = depth;
}

static inline void unlock_kernel(void)
{
	if (unlikely(current->lock_depth < 0))
		BUG();
	if (likely(--current->lock_depth < 0))
		put_kernel_lock();
}

#else

#define lock_kernel()				do { } while(0)
#define unlock_kernel()				do { } while(0)
#define release_kernel_lock(task)		do { } while(0)
#define reacquire_kernel_lock(task)		do { } while(0)
#define kernel_locked()				1

#endif /* CONFIG_SMP || CONFIG_PREEMPT */
#endif /* __LINUX_SMPLOCK_H */
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy