İşletim Sistemleri (Bahar-2016) Hafta-11/2

 #include<iostream>
 #include<signal.h>
 #include<pthread.h>
 #include<sys/syscall.h>
 #include <unistd.h>
 
 using namespace std;

 void * iplik_islem1(void *arg)
 {
	cout<<"Kimligim(1):"<<syscall(SYS_gettid)<<"--"<<endl;
 }
 
 void * iplik_islem2(void *arg)
 {
	cout<<"Kimligim(2):"<<syscall(SYS_gettid)<<"--"<<endl;
 }
 
 int main()
 {
 	pthread_t iplik[10];	
 	int i;	
 
 cout<<"Program:: create"<<endl;
 	for(i=0;i<10;i++)
 		if(i%2==0)
 			pthread_create(&iplik[i],NULL,iplik_islem1,NULL);
 		else
 			pthread_create(&iplik[i],NULL,iplik_islem2,NULL);			

 cout<<"Program:: join"<<endl;
	for(i=0;i<10;i++)
		pthread_join(iplik[i],NULL);
		 
 }

 

Share