Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SWIFTsim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
SWIFT
SWIFTsim
Commits
6a6f4b10
Commit
6a6f4b10
authored
11 years ago
by
Pedro Gonnet
Browse files
Options
Downloads
Patches
Plain Diff
let the scheduler handle task tic/toc/tid.
Former-commit-id: e76e5d26d10fc83601c088a4fde30b66effd6129
parent
6a0658f7
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
src/runner.c
+0
-3
0 additions, 3 deletions
src/runner.c
src/scheduler.c
+22
-13
22 additions, 13 deletions
src/scheduler.c
with
22 additions
and
16 deletions
src/runner.c
+
0
−
3
View file @
6a6f4b10
...
...
@@ -793,10 +793,8 @@ void *runner_main ( void *data ) {
/* Get the cells. */
ci
=
t
->
ci
;
cj
=
t
->
cj
;
t
->
rid
=
r
->
id
;
/* Different types of tasks... */
t
->
tic
=
getticks
();
switch
(
t
->
type
)
{
case
task_type_self
:
if
(
t
->
subtype
==
task_subtype_density
)
...
...
@@ -838,7 +836,6 @@ void *runner_main ( void *data ) {
default:
error
(
"Unknown task type."
);
}
t
->
toc
=
getticks
();
/* We're done with this task. */
scheduler_done
(
sched
,
t
);
...
...
This diff is collapsed.
Click to expand it.
src/scheduler.c
+
22
−
13
View file @
6a6f4b10
...
...
@@ -687,7 +687,7 @@ void scheduler_done ( struct scheduler *s , struct task *t ) {
int
k
,
res
;
struct
task
*
t2
;
/* Release whatever locks this task held. */
switch
(
t
->
type
)
{
case
task_type_self
:
...
...
@@ -714,6 +714,7 @@ void scheduler_done ( struct scheduler *s , struct task *t ) {
/* Task definitely done. */
if
(
!
t
->
implicit
)
{
t
->
toc
=
getticks
();
pthread_mutex_lock
(
&
s
->
sleep_mutex
);
atomic_dec
(
&
s
->
waiting
);
pthread_cond_broadcast
(
&
s
->
sleep_cond
);
...
...
@@ -734,21 +735,21 @@ void scheduler_done ( struct scheduler *s , struct task *t ) {
struct
task
*
scheduler_gettask
(
struct
scheduler
*
s
,
int
qid
)
{
struct
task
*
res
;
struct
task
*
res
=
NULL
;
int
k
,
nr_queues
=
s
->
nr_queues
;
/* Loop as long as there are tasks... */
while
(
s
->
waiting
>
0
)
{
while
(
s
->
waiting
>
0
&&
res
==
NULL
)
{
/* Try more than once before sleeping. */
for
(
int
tries
=
0
;
tries
<
scheduler_flag_maxsteal
;
tries
++
)
{
for
(
int
tries
=
0
;
res
==
NULL
&&
tries
<
scheduler_flag_maxsteal
;
tries
++
)
{
/* Try to get a task from the suggested queue. */
if
(
(
res
=
queue_gettask
(
&
s
->
queues
[
qid
]
,
qid
,
0
)
)
!=
NULL
)
re
turn
res
;
b
re
ak
;
/* If unsucessful, try stealing from the
largest
queue. */
if
(
s
->
flags
&
scheduler_flag_steal
){
/* If unsucessful, try stealing from the
other
queue
s
. */
if
(
s
->
flags
&
scheduler_flag_steal
)
{
int
qids
[
nr_queues
];
for
(
k
=
0
;
k
<
nr_queues
;
k
++
)
qids
[
k
]
=
k
;
...
...
@@ -759,22 +760,30 @@ struct task *scheduler_gettask ( struct scheduler *s , int qid ) {
if
(
temp
==
qid
)
continue
;
if
(
s
->
queues
[
temp
].
count
>
0
&&
(
res
=
queue_gettask
(
&
s
->
queues
[
temp
]
,
qid
,
0
)
)
!=
NULL
)
re
turn
res
;
b
re
ak
;
}
}
}
/* If we failed, take a short nap. */
pthread_mutex_lock
(
&
s
->
sleep_mutex
);
if
(
s
->
waiting
>
0
)
pthread_cond_wait
(
&
s
->
sleep_cond
,
&
s
->
sleep_mutex
);
pthread_mutex_unlock
(
&
s
->
sleep_mutex
);
if
(
res
==
NULL
)
{
pthread_mutex_lock
(
&
s
->
sleep_mutex
);
if
(
s
->
waiting
>
0
)
pthread_cond_wait
(
&
s
->
sleep_cond
,
&
s
->
sleep_mutex
);
pthread_mutex_unlock
(
&
s
->
sleep_mutex
);
}
}
/* Start the timer on this task, if we got one. */
if
(
res
!=
NULL
)
{
res
->
tic
=
getticks
();
res
->
rid
=
qid
;
}
/* No milk today. */
return
NULL
;
return
res
;
}
...
...
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