#include #include #include #include "lve_debug.h" #include "lve_task_locker.h" #define TLOCKER_ARRAY_BITS 10 #define TLOCKER_ARRAY_SZ (1 << TLOCKER_ARRAY_BITS) static struct mutex tlocker_array[TLOCKER_ARRAY_SZ]; static unsigned lve_task_hash(struct task_struct *tsk) { return hash_long((unsigned long)tsk, TLOCKER_ARRAY_BITS); } void lve_task_lock(struct task_struct *tsk) { mutex_lock(&tlocker_array[lve_task_hash(tsk)]); } void lve_task_unlock(struct task_struct *tsk) { mutex_unlock(&tlocker_array[lve_task_hash(tsk)]); } int lve_task_lock_init(void) { int i; for (i = 0; i < TLOCKER_ARRAY_SZ; i++) mutex_init(&tlocker_array[i]); return 0; } void lve_task_lock_fini(void) { }