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
7b7eaca9
Commit
7b7eaca9
authored
11 years ago
by
Pedro Gonnet
Browse files
Options
Downloads
Patches
Plain Diff
added flag to wait for queue lock or not.
parent
d547fdaf
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/qsched.c
+2
-2
2 additions, 2 deletions
src/qsched.c
src/queue.c
+9
-4
9 additions, 4 deletions
src/queue.c
src/queue.h
+2
-2
2 additions, 2 deletions
src/queue.h
with
13 additions
and
8 deletions
src/qsched.c
+
2
−
2
View file @
7b7eaca9
...
...
@@ -719,7 +719,7 @@ struct task *qsched_gettask ( struct qsched *s , int qid ) {
/* Try to get a task from my own queue. */
{
TIMER_TIC
tid
=
queue_get
(
&
s
->
queues
[
qid
]
,
s
);
tid
=
queue_get
(
&
s
->
queues
[
qid
]
,
s
,
1
);
TIMER_TOC
(
s
,
qsched_timer_queue
)
if
(
tid
<
0
)
{
...
...
@@ -730,7 +730,7 @@ struct task *qsched_gettask ( struct qsched *s , int qid ) {
while
(
naq
>
0
)
{
k
=
rand
()
%
naq
;
TIMER_TIC2
tid
=
queue_get
(
&
s
->
queues
[
qids
[
k
]
]
,
s
);
tid
=
queue_get
(
&
s
->
queues
[
qids
[
k
]
]
,
s
,
0
);
TIMER_TOC
(
s
,
qsched_timer_queue
)
if
(
tid
<
0
)
qids
[
k
]
=
qids
[
--
naq
];
...
...
This diff is collapsed.
Click to expand it.
src/queue.c
+
9
−
4
View file @
7b7eaca9
...
...
@@ -40,11 +40,12 @@
*
* @param q The #queue.
* @param s The #sched in which this queue's tasks lives.
* @param insists If set, wait at the queue's lock, otherwise fail.
*
* @return The task ID or -1 if no available task could be found.
*/
int
queue_get
(
struct
queue
*
q
,
struct
qsched
*
s
)
{
int
queue_get
(
struct
queue
*
q
,
struct
qsched
*
s
,
int
insist
)
{
int
k
,
j
,
temp
,
tid
,
*
inds
,
w
,
count
;
struct
task
*
tasks
=
s
->
tasks
;
...
...
@@ -55,8 +56,12 @@ int queue_get ( struct queue *q , struct qsched *s ) {
/* Lock this queue. */
TIMER_TIC
if
(
lock_lock
(
&
q
->
lock
)
!=
0
)
error
(
"Failed to lock queue."
);
if
(
insist
)
{
if
(
lock_lock
(
&
q
->
lock
)
!=
0
)
error
(
"Failed to lock queue."
);
}
else
if
(
lock_trylock
(
&
q
->
lock
)
!=
0
)
return
qsched_task_none
;
TIMER_TOC
(
s
,
qsched_timer_qlock
);
/* Get a pointer to the indices. */
...
...
@@ -103,7 +108,7 @@ int queue_get ( struct queue *q , struct qsched *s ) {
/* Otherwise, clear the task ID. */
else
tid
=
-
1
;
tid
=
qsched_task_none
;
/* Unlock the queue. */
lock_unlock_blind
(
&
q
->
lock
);
...
...
This diff is collapsed.
Click to expand it.
src/queue.h
+
2
−
2
View file @
7b7eaca9
...
...
@@ -36,11 +36,11 @@ struct queue {
/* Maximum number of tasks in queue. */
int
size
;
};
}
__attribute__
((
aligned
(
128
)))
;
/* Function prototypes. */
int
queue_get
(
struct
queue
*
q
,
struct
qsched
*
s
);
int
queue_get
(
struct
queue
*
q
,
struct
qsched
*
s
,
int
insist
);
void
queue_put
(
struct
queue
*
q
,
struct
qsched
*
s
,
int
tid
);
void
queue_init
(
struct
queue
*
q
,
int
size
);
void
queue_free
(
struct
queue
*
q
);
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