Skip to content

Commit c4c5c6e

Browse files
authored
Merge pull request #136 from ronawho/add-task-spawn-reset
Add a mechanism to reset the default task spawn order
2 parents dc880eb + 2fb7e8a commit c4c5c6e

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

include/qthread/qthread.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,9 @@ int qthread_spawn(qthread_f f,
333333
/* This is a function to move a thread from one shepherd to another. */
334334
int qthread_migrate_to(const qthread_shepherd_id_t shepherd);
335335

336+
/* Resets the default shepherd spawn order for tasks that use NO_SHEPHERD */
337+
void qthread_reset_target_shep(void);
338+
336339
/* This function sets the debug level if debugging has been enabled */
337340
int qthread_debuglevel(int);
338341

src/qthread.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3000,6 +3000,19 @@ int API_FUNC qthread_migrate_to(const qthread_shepherd_id_t shepherd)
30003000
}
30013001
} /*}}} */
30023002

3003+
void API_FUNC qthread_reset_target_shep(void) {
3004+
assert(qthread_library_initialized);
3005+
qthread_t *me = qthread_internal_self();
3006+
3007+
if (me) {
3008+
assert(me->rdata);
3009+
me->rdata->shepherd_ptr->sched_shepherd = 0;
3010+
} else {
3011+
qlib->sched_shepherd = 0;
3012+
MACHINE_FENCE;
3013+
}
3014+
}
3015+
30033016

30043017
/* These are just accessor functions */
30053018
unsigned int API_FUNC qthread_id(void)

0 commit comments

Comments
 (0)