Lab5
This commit is contained in:
+37
@@ -0,0 +1,37 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include <pthread.h>
|
||||
#include <unistd.h>
|
||||
|
||||
/*
|
||||
pthread_t phread_self(void);
|
||||
|
||||
void * start_routine(void * arg);
|
||||
int pthread_create(pthread_t * thread, const pthread_attr_t * attr,
|
||||
void *(start_routine)(void *), void * arg);
|
||||
void pthread_exit(void *retval);
|
||||
*/
|
||||
|
||||
void * start_routine(void * arg) {
|
||||
int pid = pthread_self();
|
||||
printf("%d\n",pid);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int main() {
|
||||
|
||||
int val1 = 5;
|
||||
int val2 = 11;
|
||||
|
||||
pthread_t thread1;
|
||||
pthread_t thread2;
|
||||
pthread_create(&thread1, NULL, &start_routine, NULL);
|
||||
pthread_create(&thread2, NULL, &start_routine, NULL);
|
||||
|
||||
|
||||
|
||||
printf("Program started!\n");
|
||||
|
||||
pthread_exit(NULL);
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user