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
ac7a9084
Commit
ac7a9084
authored
9 years ago
by
Pedro Gonnet
Browse files
Options
Downloads
Patches
Plain Diff
make sure we don't enqueue tasks twice, the non-hacky way.
parent
4bdb5527
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!136
Master
,
!66
Dynamic unlocks
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/scheduler.c
+12
-11
12 additions, 11 deletions
src/scheduler.c
with
12 additions
and
11 deletions
src/scheduler.c
+
12
−
11
View file @
ac7a9084
...
@@ -65,7 +65,7 @@ void scheduler_addunlock(struct scheduler *s, struct task *ta,
...
@@ -65,7 +65,7 @@ void scheduler_addunlock(struct scheduler *s, struct task *ta,
ta
=
ta
->
unlock_tasks
[
task_maxunlock
];
ta
=
ta
->
unlock_tasks
[
task_maxunlock
];
/* Get the index of the next free task. */
/* Get the index of the next free task. */
int
ind
=
atomic_inc
(
&
ta
->
nr_unlock_tasks
);
const
int
ind
=
atomic_inc
(
&
ta
->
nr_unlock_tasks
);
/* Is there room in this task? */
/* Is there room in this task? */
if
(
ind
<
task_maxunlock
)
{
if
(
ind
<
task_maxunlock
)
{
...
@@ -894,7 +894,7 @@ void scheduler_start(struct scheduler *s, unsigned int mask) {
...
@@ -894,7 +894,7 @@ void scheduler_start(struct scheduler *s, unsigned int mask) {
/* Clear all the waits and rids. */
/* Clear all the waits and rids. */
// ticks tic = getticks();
// ticks tic = getticks();
for
(
int
k
=
0
;
k
<
s
->
nr_tasks
;
k
++
)
{
for
(
int
k
=
0
;
k
<
s
->
nr_tasks
;
k
++
)
{
s
->
tasks
[
k
].
wait
=
0
;
s
->
tasks
[
k
].
wait
=
1
;
s
->
tasks
[
k
].
rid
=
-
1
;
s
->
tasks
[
k
].
rid
=
-
1
;
}
}
...
@@ -934,14 +934,13 @@ void scheduler_start(struct scheduler *s, unsigned int mask) {
...
@@ -934,14 +934,13 @@ void scheduler_start(struct scheduler *s, unsigned int mask) {
/* Loop over the tasks and enqueue whoever is ready. */
/* Loop over the tasks and enqueue whoever is ready. */
// tic = getticks();
// tic = getticks();
for
(
int
k
=
0
;
k
<
nr_tasks
;
k
++
)
{
for
(
int
k
=
0
;
k
<
s
->
nr_tasks
;
k
++
)
{
t
=
&
tasks
[
tid
[
k
]];
t
=
&
tasks
[
tid
[
k
]];
if
(((
1
<<
t
->
type
)
&
s
->
mask
)
&&
!
t
->
skip
)
{
if
(
atomic_dec
(
&
t
->
wait
)
==
1
&&
if
(
t
->
wait
==
0
)
{
((
1
<<
t
->
type
)
&
s
->
mask
)
&&
scheduler_enqueue
(
s
,
t
);
!
t
->
skip
)
{
pthread_cond_broadcast
(
&
s
->
sleep_cond
);
scheduler_enqueue
(
s
,
t
);
}
else
pthread_cond_broadcast
(
&
s
->
sleep_cond
);
break
;
}
}
}
}
// message( "enqueueing tasks took %.3f ms." , (double)( getticks() - tic ) /
// message( "enqueueing tasks took %.3f ms." , (double)( getticks() - tic ) /
...
@@ -962,9 +961,11 @@ void scheduler_enqueue(struct scheduler *s, struct task *t) {
...
@@ -962,9 +961,11 @@ void scheduler_enqueue(struct scheduler *s, struct task *t) {
int
err
;
int
err
;
#endif
#endif
/* Fail if this task has already been enqueued before. */
if
(
t
->
rid
>=
0
)
error
(
"Task has already been enqueued."
);
/* Ignore skipped tasks and tasks not in the mask. */
/* Ignore skipped tasks and tasks not in the mask. */
if
(
t
->
skip
||
((
1
<<
t
->
type
)
&
~
(
s
->
mask
)
&&
t
->
type
!=
task_type_link
)
||
if
(
t
->
skip
||
((
1
<<
t
->
type
)
&
~
(
s
->
mask
)
&&
t
->
type
!=
task_type_link
))
{
atomic_cas
(
&
t
->
rid
,
-
1
,
0
)
!=
-
1
)
{
return
;
return
;
}
}
...
...
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