Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pintos-skeleton
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
Container Registry
Model registry
Operate
Environments
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
Mark Wheelhouse
pintos-skeleton
Merge requests
!18
Merge patch
Code
Review changes
Check out branch
Download
Patches
Plain diff
Closed
Merge patch
lab2425_autumn/pintos_task0_ww1323:master
into
master
Overview
0
Commits
4
Pipelines
0
Changes
2
Closed
Watson, William
requested to merge
lab2425_autumn/pintos_task0_ww1323:master
into
master
3 months ago
Overview
0
Commits
4
Pipelines
0
Changes
2
Expand
0
0
Merge request reports
Compare
master
master (base)
and
latest version
latest version
5255be40
4 commits,
3 months ago
2 files
+
25
−
0
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
2
Search (e.g. *.vue) (Ctrl+P)
src/devices/timer.c
+
18
−
0
Options
@@ -24,6 +24,9 @@ static int64_t ticks;
Initialized by timer_calibrate(). */
static
unsigned
loops_per_tick
;
struct
list
sleepers
;
struct
lock
sleepers_lock
;
static
intr_handler_func
timer_interrupt
;
static
bool
too_many_loops
(
unsigned
loops
);
static
void
busy_wait
(
int64_t
loops
);
@@ -37,6 +40,9 @@ timer_init (void)
{
pit_configure_channel
(
0
,
2
,
TIMER_FREQ
);
intr_register_ext
(
0x20
,
timer_interrupt
,
"8254 Timer"
);
list_init
(
&
sleepers
);
lock_init
(
&
sleepers_lock
);
}
/* Calibrates loops_per_tick, used to implement brief delays. */
@@ -89,8 +95,20 @@ timer_elapsed (int64_t then)
void
timer_sleep
(
int64_t
ticks
)
{
if
(
ticks
<=
0
)
return
;
int64_t
start
=
timer_ticks
();
struct
list_elem
l_elem
;
struct
semaphore
sema
;
sema_init
(
&
sema
,
0
);
struct
sleeper
my_sleep
;
my_sleep
.
l_elem
=
l_elem
;
my_sleep
.
t
=
current_thread
();
my_sleep
.
waking_tick
=
start
+
ticks
;
my_sleep
.
sema
=
&
sema
;
ASSERT
(
intr_get_level
()
==
INTR_ON
);
while
(
timer_elapsed
(
start
)
<
ticks
)
thread_yield
();
Loading