İşletim Sistemleri (Bahar-2016) Hafta-7/2
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
#include<iostream> #include<unistd.h> #include<sys/wait.h> #include<stdlib.h> using namespace std; int main() { pid_t proc_id; int durum; cout<<"Basla:"<<getpid()<<endl; proc_id = fork(); if(proc_id==0) { // cocuk cout<<"Selam Ben Cocuk!"<<getpid()<<endl; //exit(0); sleep(60); } else { // anne waitpid(proc_id,&durum,0); cout<<"Sonlanma:"<<durum<<endl; } return 0; } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
#include<iostream> #include<unistd.h> #include<sys/wait.h> #include<stdlib.h> using namespace std; int main() { pid_t proc_id; int durum; cout<<"Basla:"<<getpid()<<" ::"<<SIGKILL<<endl; proc_id = fork(); if(proc_id==0) { // cocuk cout<<"Selam Ben Cocuk!"<<endl; //exit(0); } else { // anne kill(proc_id,SIGSTOP); waitpid(proc_id,&durum,0); cout<<"Sonlanma:"<<durum<<endl; } return 0; } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
#include<iostream> #include<unistd.h> #include<sys/wait.h> using namespace std; int main() { pid_t proc_id; int durum; cout<<"Basla::"<<getpid()<<endl; proc_id=fork(); if(proc_id==0) { cout<<"Ben Cocuk!::"<<getpid()<<endl; sleep(10); } else { cout<<"Ben Anne::"<<getpid()<<" Cocugun id::"<<proc_id<<endl; //kill(proc_id,SIGTERM); kill(proc_id,SIGSTOP); sleep(5); kill(proc_id,SIGCONT); waitpid(proc_id,&durum,0); cout<<"Sonlanma::"<<durum<<endl; } return 0; } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
#include<iostream> #include<unistd.h> #include<sys/wait.h> #include<stdlib.h> using namespace std; int main() { pid_t proc_id; int durum; cout<<"Basla:"<<getpid()<<endl; proc_id = fork(); if(proc_id==0) { // cocuk cout<<"Selam Ben Cocuk!"<<endl; int x=0, y=0; int z=x/y; sleep(50); } else { // anne waitpid(proc_id,&durum,0); cout<<"Sonlanma:"<<durum<<endl; } return 0; } |
Okumaya devam et
Son Yorumlar