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
ed94ec26
Commit
ed94ec26
authored
11 years ago
by
Pedro Gonnet
Browse files
Options
Downloads
Patches
Plain Diff
try more than once to get a task before sleeping.
Former-commit-id: 458a6f26e877376b6bb0f74c835c04954c691959
parent
84a9f7fe
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/scheduler.c
+21
-24
21 additions, 24 deletions
src/scheduler.c
src/scheduler.h
+1
-0
1 addition, 0 deletions
src/scheduler.h
with
22 additions
and
24 deletions
src/scheduler.c
+
21
−
24
View file @
ed94ec26
...
...
@@ -662,32 +662,29 @@ struct task *scheduler_gettask ( struct scheduler *s , int qid ) {
/* Loop as long as there are tasks... */
while
(
s
->
waiting
>
0
)
{
/* Try to get a task from the suggested queue. */
if
(
(
res
=
queue_gettask
(
&
s
->
queues
[
qid
]
,
qid
,
0
)
)
!=
NULL
)
return
res
;
/* If unsucessful, try stealing from the largest queue. */
if
(
s
->
flags
&
scheduler_flag_steal
)
{
int
qids
[
nr_queues
];
for
(
k
=
0
;
k
<
nr_queues
;
k
++
)
qids
[
k
]
=
k
;
/* int max_count = 0, max_ind = 0;
for ( k = 0 ; k < nr_queues ; k++ )
if ( k != qid && s->queues[k].count > max_count ) {
max_ind = k;
max_count = s->queues[k].count;
/* Try more than once before sleeping. */
for
(
int
tries
=
0
;
tries
<
scheduler_flag_maxsteal
;
tries
++
)
{
/* Try to get a task from the suggested queue. */
if
(
(
res
=
queue_gettask
(
&
s
->
queues
[
qid
]
,
qid
,
0
)
)
!=
NULL
)
return
res
;
/* If unsucessful, try stealing from the largest queue. */
if
(
s
->
flags
&
scheduler_flag_steal
){
int
qids
[
nr_queues
];
for
(
k
=
0
;
k
<
nr_queues
;
k
++
)
qids
[
k
]
=
k
;
for
(
k
=
0
;
k
<
nr_queues
;
k
++
)
{
int
j
=
k
+
(
rand
()
%
(
nr_queues
-
k
)
);
int
temp
=
qids
[
j
];
qids
[
j
]
=
qids
[
k
];
if
(
temp
==
qid
)
continue
;
if
(
s
->
queues
[
temp
].
count
>
0
&&
(
res
=
queue_gettask
(
&
s
->
queues
[
temp
]
,
qid
,
0
)
)
!=
NULL
)
return
res
;
}
if ( max_count > 0 && ( res = queue_gettask( &s->queues[ max_ind ] , qid , 0 ) ) != NULL )
return res; */
for
(
k
=
0
;
k
<
nr_queues
;
k
++
)
{
if
(
k
==
qid
)
continue
;
int
j
=
k
+
(
rand
()
%
(
nr_queues
-
k
)
);
int
temp
=
qids
[
j
];
qids
[
j
]
=
qids
[
k
];
if
(
s
->
queues
[
temp
].
count
>
0
&&
(
res
=
queue_gettask
(
&
s
->
queues
[
temp
]
,
qid
,
0
)
)
!=
NULL
)
return
res
;
}
}
/* If we failed, take a short nap. */
...
...
This diff is collapsed.
Click to expand it.
src/scheduler.h
+
1
−
0
View file @
ed94ec26
...
...
@@ -27,6 +27,7 @@
/* Flags . */
#define scheduler_flag_none 0
#define scheduler_flag_steal 1
#define scheduler_flag_maxsteal 2
/* Data of a scheduler. */
...
...
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