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
6e4ceaa3
Commit
6e4ceaa3
authored
11 years ago
by
Pedro Gonnet
Browse files
Options
Downloads
Patches
Plain Diff
queue heap was broken, set initial cell ownership to -1.
Former-commit-id: 2e6c10ea4fedda261314bce1352603f33089fe17
parent
6b9d8181
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/queue.c
+30
-15
30 additions, 15 deletions
src/queue.c
src/space.c
+1
-0
1 addition, 0 deletions
src/space.c
with
31 additions
and
15 deletions
src/queue.c
+
30
−
15
View file @
6e4ceaa3
...
...
@@ -103,14 +103,19 @@ void queue_insert ( struct queue *q , struct task *t ) {
q
->
count
+=
1
;
/* Shuffle up. */
for
(
int
k
=
q
->
count
-
1
;
k
>
0
;
k
/
=
2
)
if
(
q
->
tasks
[
q
->
tid
[
k
]
].
weight
>
q
->
tasks
[
q
->
tid
[
k
/
2
]
].
weight
)
{
for
(
int
k
=
q
->
count
-
1
;
k
>
0
;
k
=
(
k
-
1
)
/
2
)
if
(
q
->
tasks
[
q
->
tid
[
k
]
].
weight
>
q
->
tasks
[
q
->
tid
[
(
k
-
1
)
/
2
]
].
weight
)
{
int
temp
=
q
->
tid
[
k
];
q
->
tid
[
k
]
=
q
->
tid
[
k
/
2
];
q
->
tid
[
k
/
2
]
=
temp
;
q
->
tid
[
k
]
=
q
->
tid
[
(
k
-
1
)
/
2
];
q
->
tid
[
(
k
-
1
)
/
2
]
=
temp
;
}
else
break
;
/* Verify queue consistency. */
/* for ( int k = 1 ; k < q->count ; k++ )
if ( q->tasks[ q->tid[(k-1)/2] ].weight < q->tasks[ q->tid[k] ].weight )
error( "Queue not heaped." ); */
/* Unlock the queue. */
if
(
lock_unlock
(
&
q
->
lock
)
!=
0
)
...
...
@@ -156,7 +161,7 @@ void queue_init ( struct queue *q , struct task *tasks ) {
struct
task
*
queue_gettask
(
struct
queue
*
q
,
int
qid
,
int
blocking
)
{
int
k
,
qcount
,
*
qtid
,
type
;
int
k
,
kk
,
i
,
temp
,
qcount
,
*
qtid
,
type
;
lock_type
*
qlock
=
&
q
->
lock
;
struct
task
*
qtasks
,
*
res
=
NULL
;
struct
cell
*
ci
,
*
cj
;
...
...
@@ -178,9 +183,9 @@ struct task *queue_gettask ( struct queue *q , int qid , int blocking ) {
/* Set some pointers we will use often. */
qtid
=
q
->
tid
;
qtasks
=
q
->
tasks
;
qcount
=
q
->
count
;
/* Loop over the remaining task IDs. */
qcount
=
q
->
count
;
for
(
k
=
0
;
k
<
qcount
;
k
++
)
{
/* Put a finger on the task. */
...
...
@@ -220,7 +225,7 @@ struct task *queue_gettask ( struct queue *q , int qid , int blocking ) {
if
(
k
<
qcount
)
{
/* Another one bites the dust. */
q
->
count
-=
1
;
qcount
=
q
->
count
-=
1
;
/* Own the cells involved. */
ci
->
super
->
owner
=
qid
;
...
...
@@ -228,16 +233,21 @@ struct task *queue_gettask ( struct queue *q , int qid , int blocking ) {
cj
->
super
->
owner
=
qid
;
/* Swap this task with the last task and re-heap. */
if
(
k
<
q
->
count
)
{
qtid
[
k
]
=
qtid
[
q
->
count
];
while
(
1
)
{
int
i
=
2
*
k
;
if
(
i
>=
q
->
count
)
break
;
if
(
i
+
1
<
q
->
count
&&
qtasks
[
qtid
[
i
+
1
]
].
weight
>
qtasks
[
qtid
[
i
]
].
weight
)
kk
=
k
;
k
=
kk
;
if
(
k
<
qcount
)
{
qtid
[
k
]
=
qtid
[
qcount
];
while
(
qtasks
[
qtid
[
k
]
].
weight
>
qtasks
[
qtid
[(
k
-
1
)
/
2
]
].
weight
)
{
int
temp
=
q
->
tid
[
k
];
q
->
tid
[
k
]
=
q
->
tid
[(
k
-
1
)
/
2
];
q
->
tid
[(
k
-
1
)
/
2
]
=
temp
;
k
=
(
k
-
1
)
/
2
;
}
while
(
(
i
=
2
*
k
+
1
)
<
qcount
)
{
if
(
i
+
1
<
qcount
&&
qtasks
[
qtid
[
i
+
1
]
].
weight
>
qtasks
[
qtid
[
i
]
].
weight
)
i
+=
1
;
if
(
qtasks
[
qtid
[
i
]
].
weight
>
qtasks
[
qtid
[
k
]
].
weight
)
{
int
temp
=
qtid
[
i
];
temp
=
qtid
[
i
];
qtid
[
i
]
=
qtid
[
k
];
qtid
[
k
]
=
temp
;
k
=
i
;
...
...
@@ -247,6 +257,11 @@ struct task *queue_gettask ( struct queue *q , int qid , int blocking ) {
}
}
/* Verify queue consistency. */
/* for ( k = 1 ; k < q->count ; k++ )
if ( q->tasks[ q->tid[(k-1)/2] ].weight < q->tasks[ q->tid[k] ].weight )
error( "Queue not heaped." ); */
}
else
res
=
NULL
;
...
...
This diff is collapsed.
Click to expand it.
src/space.c
+
1
−
0
View file @
6e4ceaa3
...
...
@@ -758,6 +758,7 @@ struct cell *space_getcell ( struct space *s ) {
bzero
(
c
,
sizeof
(
struct
cell
)
);
if
(
lock_init
(
&
c
->
lock
)
!=
0
)
error
(
"Failed to initialize cell spinlock."
);
c
->
owner
=
-
1
;
/* Unlock the space. */
lock_unlock_blind
(
&
s
->
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