Skip to content

Commit

Permalink
Merge pull request #136 from ronawho/add-task-spawn-reset
Browse files Browse the repository at this point in the history
Add a mechanism to reset the default task spawn order
  • Loading branch information
janciesko authored Aug 28, 2023
2 parents dc880eb + 2fb7e8a commit c4c5c6e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions include/qthread/qthread.h
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,9 @@ int qthread_spawn(qthread_f f,
/* This is a function to move a thread from one shepherd to another. */
int qthread_migrate_to(const qthread_shepherd_id_t shepherd);

/* Resets the default shepherd spawn order for tasks that use NO_SHEPHERD */
void qthread_reset_target_shep(void);

/* This function sets the debug level if debugging has been enabled */
int qthread_debuglevel(int);

Expand Down
13 changes: 13 additions & 0 deletions src/qthread.c
Original file line number Diff line number Diff line change
Expand Up @@ -3000,6 +3000,19 @@ int API_FUNC qthread_migrate_to(const qthread_shepherd_id_t shepherd)
}
} /*}}} */

void API_FUNC qthread_reset_target_shep(void) {
assert(qthread_library_initialized);
qthread_t *me = qthread_internal_self();

if (me) {
assert(me->rdata);
me->rdata->shepherd_ptr->sched_shepherd = 0;
} else {
qlib->sched_shepherd = 0;
MACHINE_FENCE;
}
}


/* These are just accessor functions */
unsigned int API_FUNC qthread_id(void)
Expand Down

0 comments on commit c4c5c6e

Please sign in to comment.