Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- is nice() used to change the thread priority or the process priority?
- void * thread_function1(void *arg)
- {
- pid_t tid = syscall(SYS_gettid);
- int ret = setpriority(PRIO_PROCESS, tid, -10);
- printf("tid of high priority thread %d , %dn",tid ,getpriority(PRIO_PROCESS,tid));
- while(1){
- printf("high priority ................n");
- }
- }
- void * thread_function(void *arg)
- {
- pid_t tid = syscall(SYS_gettid);
- int ret = setpriority(PRIO_PROCESS, tid, 10);
- printf("tid of low priority thread %d , %d n",tid ,getpriority(PRIO_PROCESS,tid));
- while(1)
- {
- printf("lower priorityn");
- }
- }
- int main()
- {
- pthread_t id1;
- pthread_t id2;
- pid_t pid = getpid();
- pid_t tid = syscall(SYS_gettid);
- printf("main thread : pid = %d , tid = %d n" , pid, tid);
- pthread_create(&id1, NULL, thread_function1, NULL);
- pthread_create(&id1, NULL,thread_function, NULL);
- pthread_join(id1, NULL);
- pthread_join(id2, NULL);
- }
Add Comment
Please, Sign In to add comment