I was curious how you go about setting priorities for pthreads using a mutex in C. I want to be sure my threads receive the lock in the order they should based off some priority value. I've done a little digging and found
pthread_mutexattr_getprotocol()
and
pthread_mutexattr_setprotocol()
Is this something that accomplishes what I want to do? Thanks.
I do not see where mutexes fit into this - thread priority
pthread_setschedparam(pthread_t thread, int policy,
const struct sched_param *param);
pthread_getschedparam(pthread_t thread, int *policy,
struct sched_param *param);
Try those. Assuming I understand what you want...
Try pthread_barrier_wait
to force threads to wait for everybody else to complete something.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.