Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
QuickSched
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
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
QuickSched
Commits
a504ff46
Commit
a504ff46
authored
10 years ago
by
Pedro Gonnet
Browse files
Options
Downloads
Patches
Plain Diff
more cleanup.
parent
162f50c3
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/qsched.c
+26
-24
26 additions, 24 deletions
src/qsched.c
with
26 additions
and
24 deletions
src/qsched.c
+
26
−
24
View file @
a504ff46
...
@@ -537,8 +537,6 @@ void *qsched_getdata(struct qsched *s, struct task *t) {
...
@@ -537,8 +537,6 @@ void *qsched_getdata(struct qsched *s, struct task *t) {
void
qsched_enqueue
(
struct
qsched
*
s
,
struct
task
*
t
)
{
void
qsched_enqueue
(
struct
qsched
*
s
,
struct
task
*
t
)
{
int
j
,
qid
,
scores
[
s
->
nr_queues
],
oid
;
/* If this is a virtual task, just do its unlocks and leave. */
/* If this is a virtual task, just do its unlocks and leave. */
if
(
t
->
flags
&
task_flag_virtual
)
{
if
(
t
->
flags
&
task_flag_virtual
)
{
...
@@ -552,23 +550,28 @@ void qsched_enqueue(struct qsched *s, struct task *t) {
...
@@ -552,23 +550,28 @@ void qsched_enqueue(struct qsched *s, struct task *t) {
else
{
else
{
/* Init the scores for each queue. */
/* Init the scores for each queue. */
for
(
j
=
0
;
j
<
s
->
nr_queues
;
j
++
)
scores
[
j
]
=
0
;
int
scores
[
s
->
nr_queues
];
for
(
int
j
=
0
;
j
<
s
->
nr_queues
;
j
++
)
scores
[
j
]
=
0
;
/* Loop over the locks and uses, and get their owners. */
/* Loop over the locks and uses, and get their owners. */
for
(
j
=
0
;
j
<
t
->
nr_locks
;
j
++
)
for
(
int
j
=
0
;
j
<
t
->
nr_locks
;
j
++
)
{
if
((
oid
=
s
->
res
[
t
->
locks
[
j
]].
owner
)
!=
qsched_owner_none
)
int
oid
=
s
->
res
[
t
->
locks
[
j
]].
owner
;
scores
[
oid
]
+=
1
;
if
(
oid
!=
qsched_owner_none
)
scores
[
oid
]
+=
1
;
for
(
j
=
0
;
j
<
t
->
nr_uses
;
j
++
)
}
if
((
oid
=
s
->
res
[
t
->
uses
[
j
]].
owner
)
!=
qsched_owner_none
)
for
(
int
j
=
0
;
j
<
t
->
nr_uses
;
j
++
)
{
scores
[
oid
]
+=
1
;
int
oid
=
s
->
res
[
t
->
uses
[
j
]].
owner
;
if
(
oid
!=
qsched_owner_none
)
scores
[
oid
]
+=
1
;
}
/* Find the queue with the highest score. */
/* Find the queue with the highest score. */
qid
=
0
;
int
qid
=
0
;
for
(
j
=
1
;
j
<
s
->
nr_queues
;
j
++
)
for
(
int
j
=
1
;
j
<
s
->
nr_queues
;
j
++
)
{
if
(
scores
[
j
]
>
scores
[
qid
]
||
if
(
scores
[
j
]
>
scores
[
qid
]
||
(
scores
[
j
]
==
scores
[
qid
]
&&
(
scores
[
j
]
==
scores
[
qid
]
&&
s
->
queues
[
j
].
count
<
s
->
queues
[
qid
].
count
))
s
->
queues
[
j
].
count
<
s
->
queues
[
qid
].
count
))
{
qid
=
j
;
qid
=
j
;
}
}
/* Put the unlocked task in that queue. */
/* Put the unlocked task in that queue. */
queue_put
(
&
s
->
queues
[
qid
],
s
,
t
-
s
->
tasks
);
queue_put
(
&
s
->
queues
[
qid
],
s
,
t
-
s
->
tasks
);
...
@@ -584,9 +587,6 @@ void qsched_enqueue(struct qsched *s, struct task *t) {
...
@@ -584,9 +587,6 @@ void qsched_enqueue(struct qsched *s, struct task *t) {
void
qsched_done
(
struct
qsched
*
s
,
struct
task
*
t
)
{
void
qsched_done
(
struct
qsched
*
s
,
struct
task
*
t
)
{
int
k
;
struct
task
*
t2
;
TIMER_TIC
TIMER_TIC
/* Set the task stats. */
/* Set the task stats. */
...
@@ -594,17 +594,18 @@ void qsched_done(struct qsched *s, struct task *t) {
...
@@ -594,17 +594,18 @@ void qsched_done(struct qsched *s, struct task *t) {
if
(
!
(
s
->
flags
&
qsched_flag_norecost
))
t
->
cost
=
t
->
toc
-
t
->
tic
;
if
(
!
(
s
->
flags
&
qsched_flag_norecost
))
t
->
cost
=
t
->
toc
-
t
->
tic
;
/* Release this task's locks. */
/* Release this task's locks. */
for
(
k
=
0
;
k
<
t
->
nr_locks
;
k
++
)
qsched_unlockres
(
s
,
t
->
locks
[
k
]);
for
(
int
k
=
0
;
k
<
t
->
nr_locks
;
k
++
)
qsched_unlockres
(
s
,
t
->
locks
[
k
]);
/* Loop over the task's unlocks... */
/* Loop over the task's unlocks... */
for
(
k
=
0
;
k
<
t
->
nr_unlocks
;
k
++
)
{
for
(
int
k
=
0
;
k
<
t
->
nr_unlocks
;
k
++
)
{
/* Get a grip on the unlocked task. */
/* Get a grip on the unlocked task. */
t2
=
&
s
->
tasks
[
t
->
unlocks
[
k
]];
struct
task
*
t2
=
&
s
->
tasks
[
t
->
unlocks
[
k
]];
/* Is the unlocked task ready to run? */
/* Is the unlocked task ready to run? */
if
(
atomic_dec
(
&
t2
->
wait
)
==
1
&&
!
(
t2
->
flags
&
task_flag_skip
))
if
(
atomic_dec
(
&
t2
->
wait
)
==
1
&&
!
(
t2
->
flags
&
task_flag_skip
))
{
qsched_enqueue
(
s
,
t2
);
qsched_enqueue
(
s
,
t2
);
}
}
}
/* Decrease the number of tasks in this space. */
/* Decrease the number of tasks in this space. */
...
@@ -635,8 +636,6 @@ void qsched_done(struct qsched *s, struct task *t) {
...
@@ -635,8 +636,6 @@ void qsched_done(struct qsched *s, struct task *t) {
int
qsched_lockres
(
struct
qsched
*
s
,
int
rid
)
{
int
qsched_lockres
(
struct
qsched
*
s
,
int
rid
)
{
int
finger
,
finger2
;
/* Try to lock the root-level resource. */
/* Try to lock the root-level resource. */
if
(
s
->
res
[
rid
].
hold
||
lock_trylock
(
&
s
->
res
[
rid
].
lock
))
return
0
;
if
(
s
->
res
[
rid
].
hold
||
lock_trylock
(
&
s
->
res
[
rid
].
lock
))
return
0
;
...
@@ -648,6 +647,7 @@ int qsched_lockres(struct qsched *s, int rid) {
...
@@ -648,6 +647,7 @@ int qsched_lockres(struct qsched *s, int rid) {
/* Follow parents and increase their hold counter, but fail
/* Follow parents and increase their hold counter, but fail
if any are locked. */
if any are locked. */
int
finger
;
for
(
finger
=
s
->
res
[
rid
].
parent
;
finger
!=
qsched_res_none
;
for
(
finger
=
s
->
res
[
rid
].
parent
;
finger
!=
qsched_res_none
;
finger
=
s
->
res
[
finger
].
parent
)
{
finger
=
s
->
res
[
finger
].
parent
)
{
if
(
lock_trylock
(
&
s
->
res
[
finger
].
lock
))
break
;
if
(
lock_trylock
(
&
s
->
res
[
finger
].
lock
))
break
;
...
@@ -662,9 +662,10 @@ int qsched_lockres(struct qsched *s, int rid) {
...
@@ -662,9 +662,10 @@ int qsched_lockres(struct qsched *s, int rid) {
lock_unlock_blind
(
&
s
->
res
[
rid
].
lock
);
lock_unlock_blind
(
&
s
->
res
[
rid
].
lock
);
/* Go back up the tree and undo the holds. */
/* Go back up the tree and undo the holds. */
for
(
finger2
=
s
->
res
[
rid
].
parent
;
finger2
!=
finger
;
for
(
int
finger2
=
s
->
res
[
rid
].
parent
;
finger2
!=
finger
;
finger2
=
s
->
res
[
finger2
].
parent
)
finger2
=
s
->
res
[
finger2
].
parent
)
{
atomic_dec
(
&
s
->
res
[
finger2
].
hold
);
atomic_dec
(
&
s
->
res
[
finger2
].
hold
);
}
/* Fail. */
/* Fail. */
return
0
;
return
0
;
...
@@ -672,8 +673,9 @@ int qsched_lockres(struct qsched *s, int rid) {
...
@@ -672,8 +673,9 @@ int qsched_lockres(struct qsched *s, int rid) {
}
}
/* Otherwise, all went well. */
/* Otherwise, all went well. */
else
else
{
return
1
;
return
1
;
}
}
}
/**
/**
...
...
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