Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
triazo
/
kernel
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
3
Merge Requests
0
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
50a1ffb3
authored
Nov 29, 2015
by
malcolm
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
mutexes. not very pretty atm
parent
cc18f318
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
0 deletions
src/mutex.c
src/mutex.h
src/mutex.c
0 → 100644
View file @
50a1ffb3
#include "mutex.h"
uint32_t
mutex_lock
(
mutex
m
)
{
asm
volatile
(
"mov $1, %%eax; \
xchg %[lock], %%eax; \
mov %%eax, %[value]"
:
[
value
]
"=r"
(
m
.
value
)
:
[
lock
]
"r"
(
m
.
lock_var
)
);
return
m
.
value
;
}
uint32_t
mutex_unlock
(
mutex
m
)
{
asm
volatile
(
"mov $0, %%eax; \
xchg %[lock], %%eax; \
mov %%eax, %[value]"
:
[
value
]
"=r"
(
m
.
value
)
:
[
lock
]
"r"
(
m
.
lock_var
)
);
return
m
.
value
;
}
src/mutex.h
0 → 100644
View file @
50a1ffb3
#ifndef _MUTEX_INC
#define _MUTEX_INC
#include <stdint.h>
typedef
struct
{
uint32_t
lock_var
;
uint32_t
value
;
}
__attribute__
((
packed
))
mutex
;
uint32_t
mutex_lock
(
mutex
m
);
uint32_t
mutex_unlock
(
mutex
m
);
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment