mirror of
https://github.com/drasko/codezero.git
synced 2026-01-29 19:23:14 +01:00
Added mutex_control syscall for userspace mutexes.
- Compiles and Codezero runs as normal without touching mutex implementation - Mutex implementation needs testing. The mutex control syscall allows userspace programs to declare any virtual address as a mutex lock and ask for help from the kernel syscall for resolving locking contentions.
This commit is contained in:
@@ -78,6 +78,10 @@ typedef int (*__l4_time_t)(void *timeval, int set);
|
||||
extern __l4_time_t __l4_time;
|
||||
int l4_time(void *timeval, int set);
|
||||
|
||||
typedef int (*__l4_mutex_control_t)(void *mutex_word, int op);
|
||||
extern __l4_mutex_control_t __l4_mutex_control;
|
||||
int l4_mutex_control(void *mutex_word, int op);
|
||||
|
||||
|
||||
/* To be supplied by server tasks. */
|
||||
void *virt_to_phys(void *);
|
||||
|
||||
38
tasks/libl4/include/l4lib/mutex.h
Normal file
38
tasks/libl4/include/l4lib/mutex.h
Normal file
@@ -0,0 +1,38 @@
|
||||
|
||||
/*
|
||||
* User space locking
|
||||
*
|
||||
* Copyright (C) 2009 Bahadir Bilgehan Balban
|
||||
*/
|
||||
|
||||
#ifndef __L4_MUTEX_H__
|
||||
#define __L4_MUTEX_H__
|
||||
|
||||
|
||||
#if !defined(__ASSEMBLY__)
|
||||
|
||||
#include <l4/api/mutex.h>
|
||||
|
||||
struct l4_mutex {
|
||||
unsigned int lock;
|
||||
} __attribute__((aligned(sizeof(int))));
|
||||
|
||||
|
||||
void l4_mutex_init(struct l4_mutex *m);
|
||||
int l4_mutex_lock(struct l4_mutex *m);
|
||||
int l4_mutex_unlock(struct l4_mutex *m);
|
||||
|
||||
#endif
|
||||
|
||||
/* Mutex return value - don't mix up with mutes state */
|
||||
#define L4_MUTEX_CONTENDED -1
|
||||
#define L4_MUTEX_SUCCESS 0
|
||||
|
||||
/* Mutex states - Any valid tid value is a locked state */
|
||||
#define L4_MUTEX_UNLOCKED -1
|
||||
#define L4_MUTEX(m) \
|
||||
struct l4_mutex m = { L4_MUTEX_UNLOCKED }
|
||||
|
||||
|
||||
|
||||
#endif /* __L4_MUTEX_H__ */
|
||||
Reference in New Issue
Block a user