Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CSEP551
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
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
Krishna Vinnakota
CSEP551
Commits
564a1cf0
Commit
564a1cf0
authored
8 years ago
by
Frans Kaashoek
Browse files
Options
Downloads
Patches
Plain Diff
sleeplock files
parent
dec637bc
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
sleeplock.c
+56
-0
56 additions, 0 deletions
sleeplock.c
sleeplock.h
+10
-0
10 additions, 0 deletions
sleeplock.h
with
66 additions
and
0 deletions
sleeplock.c
0 → 100644
+
56
−
0
View file @
564a1cf0
// Sleeping locks
#include
"types.h"
#include
"defs.h"
#include
"param.h"
#include
"x86.h"
#include
"memlayout.h"
#include
"mmu.h"
#include
"proc.h"
#include
"spinlock.h"
#include
"sleeplock.h"
void
initsleeplock
(
struct
sleeplock
*
lk
,
char
*
name
)
{
initlock
(
&
lk
->
lk
,
"sleep lock"
);
lk
->
name
=
name
;
lk
->
locked
=
0
;
lk
->
pid
=
0
;
}
void
acquiresleep
(
struct
sleeplock
*
lk
)
{
acquire
(
&
lk
->
lk
);
while
(
lk
->
locked
)
{
sleep
(
lk
,
&
lk
->
lk
);
}
lk
->
locked
=
1
;
lk
->
pid
=
proc
->
pid
;
release
(
&
lk
->
lk
);
}
void
releasesleep
(
struct
sleeplock
*
lk
)
{
acquire
(
&
lk
->
lk
);
lk
->
locked
=
0
;
lk
->
pid
=
0
;
wakeup
(
lk
);
release
(
&
lk
->
lk
);
}
int
holdingsleep
(
struct
sleeplock
*
lk
)
{
int
r
;
acquire
(
&
lk
->
lk
);
r
=
lk
->
locked
;
release
(
&
lk
->
lk
);
return
r
;
}
This diff is collapsed.
Click to expand it.
sleeplock.h
0 → 100644
+
10
−
0
View file @
564a1cf0
// Long-term locks for processes
struct
sleeplock
{
uint
locked
;
// Is the lock held?
struct
spinlock
lk
;
// spinlock protecting this sleep lock
// For debugging:
char
*
name
;
// Name of lock.
int
pid
;
// Process holding lock
};
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