Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
osv
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Verlässliche Systemsoftware
projects
osv
Commits
1a80ca0f
Commit
1a80ca0f
authored
12 years ago
by
Dor Laor
Browse files
Options
Downloads
Patches
Plain Diff
Initialize class mutex and its spinlock correctly
parent
b7fcf036
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/mutex.hh
+2
-0
2 additions, 0 deletions
include/mutex.hh
include/osv/mutex.h
+9
-1
9 additions, 1 deletion
include/osv/mutex.h
with
11 additions
and
1 deletion
include/mutex.hh
+
2
−
0
View file @
1a80ca0f
...
@@ -7,6 +7,8 @@
...
@@ -7,6 +7,8 @@
class
mutex
{
class
mutex
{
public:
public:
mutex
()
{
mutex_init
(
&
_mutex
);
}
~
mutex
()
{
mutex_destroy
(
&
_mutex
);
}
void
lock
();
void
lock
();
bool
try_lock
();
bool
try_lock
();
void
unlock
();
void
unlock
();
...
...
This diff is collapsed.
Click to expand it.
include/osv/mutex.h
+
9
−
1
View file @
1a80ca0f
...
@@ -14,6 +14,11 @@ struct cspinlock {
...
@@ -14,6 +14,11 @@ struct cspinlock {
typedef
struct
cspinlock
spinlock_t
;
typedef
struct
cspinlock
spinlock_t
;
static
inline
void
spinlock_init
(
spinlock_t
*
sl
)
{
sl
->
lock
=
false
;
}
struct
cmutex
{
struct
cmutex
{
bool
_locked
;
bool
_locked
;
struct
wait_list
{
struct
wait_list
{
...
@@ -33,7 +38,10 @@ void mutex_unlock(mutex_t* m);
...
@@ -33,7 +38,10 @@ void mutex_unlock(mutex_t* m);
static
__always_inline
void
mutex_init
(
mutex_t
*
m
)
static
__always_inline
void
mutex_init
(
mutex_t
*
m
)
{
{
memset
(
m
,
0
,
sizeof
(
*
m
));
m
->
_locked
=
false
;
m
->
_wait_list
.
first
=
0
;
m
->
_wait_list
.
last
=
0
;
spinlock_init
(
&
m
->
_wait_lock
);
}
}
static
__always_inline
void
mutex_destroy
(
mutex_t
*
m
)
static
__always_inline
void
mutex_destroy
(
mutex_t
*
m
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment