Server IP : 172.16.15.8 / Your IP : 3.133.107.11 Web Server : Apache System : Linux zeus.vwu.edu 4.18.0-553.27.1.el8_10.x86_64 #1 SMP Wed Nov 6 14:29:02 UTC 2024 x86_64 User : apache ( 48) PHP Version : 7.2.24 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0755) : /home/cjabbott/cs471/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
#include <pthread.h> #include <stdio.h> int value = 0; void *runner(void *param); int main(int argc, char *argv[]) { int pid; pthread_t tid; pthread_attr_t attr; pid = fork(); if(pid ==0) { pthread_attr_init(&attr); pthread_create(&tid,&attr,runner,NULL); pthread_join(tid,NULL); printf("CHILD: value = %d", value); } else if (pid > 0) { wait(NULL); printf("PARENT: value = %d", value); } } void *runner(void *param) { value = 5; pthread_exit(0); }