-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
08d0a71
commit 8fea0da
Showing
64 changed files
with
760 additions
and
45,610 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
#include<stdio.h> | ||
#include <sys/types.h> | ||
#include<unistd.h> | ||
void forkexample() | ||
{ | ||
// child process because return value zero | ||
if (fork()==0) | ||
printf("Hello from Child!\n"); | ||
|
||
// parent process because return value non-zero. | ||
else | ||
printf("Hello from Parent!\n"); | ||
} | ||
int main() | ||
{ | ||
forkexample(); | ||
return 0; | ||
#include<stdio.h> | ||
#include <sys/types.h> | ||
#include<unistd.h> | ||
void forkexample() | ||
{ | ||
// child process because return value zero | ||
if (fork()==0) | ||
printf("Hello from Child!\n"); | ||
|
||
// parent process because return value non-zero. | ||
else | ||
printf("Hello from Parent!\n"); | ||
} | ||
int main() | ||
{ | ||
forkexample(); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,36 @@ | ||
#include <stdio.h> | ||
#include <sys/types.h> | ||
|
||
#define MAX_COUNT 5 | ||
|
||
void ChildProcess(void); /* child process prototype */ | ||
void ParentProcess(void); /* parent process prototype */ | ||
|
||
void main(void) | ||
{ | ||
pid_t pid; | ||
|
||
pid = fork(); | ||
if (pid == 0) | ||
ChildProcess(); | ||
else | ||
ParentProcess(); | ||
} | ||
|
||
void ChildProcess(void) | ||
{ | ||
int i; | ||
|
||
for (i = 1; i <= MAX_COUNT; i++) | ||
printf(" This line is from child, value = %d\n", i); | ||
printf(" *** Child process is done ***\n"); | ||
} | ||
|
||
void ParentProcess(void) | ||
{ | ||
int i; | ||
|
||
for (i = 1; i <= MAX_COUNT; i++) | ||
printf("This line is from parent, value = %d\n", i); | ||
printf("*** Parent is done ***\n"); | ||
} | ||
#include <stdio.h> | ||
#include <sys/types.h> | ||
|
||
#define MAX_COUNT 5 | ||
|
||
void ChildProcess(void); /* child process prototype */ | ||
void ParentProcess(void); /* parent process prototype */ | ||
|
||
void main(void) | ||
{ | ||
pid_t pid; | ||
|
||
pid = fork(); | ||
if (pid == 0) | ||
ChildProcess(); | ||
else | ||
ParentProcess(); | ||
} | ||
|
||
void ChildProcess(void) | ||
{ | ||
int i; | ||
|
||
for (i = 1; i <= MAX_COUNT; i++) | ||
printf(" This line is from child, value = %d\n", i); | ||
printf(" *** Child process is done ***\n"); | ||
} | ||
|
||
void ParentProcess(void) | ||
{ | ||
int i; | ||
|
||
for (i = 1; i <= MAX_COUNT; i++) | ||
printf("This line is from parent, value = %d\n", i); | ||
printf("*** Parent is done ***\n"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
#include <stdio.h> | ||
#include <string.h> | ||
#include <sys/types.h> | ||
|
||
#define MAX_COUNT 10 | ||
#define BUF_SIZE 10 | ||
|
||
void main(void) | ||
{ | ||
pid_t pid; | ||
int i; | ||
char buf[BUF_SIZE]; | ||
|
||
fork(); | ||
pid = getpid(); | ||
for (i = 1; i <= MAX_COUNT; i++) { | ||
sprintf(buf, "This line is from pid %d, value = %d\n", pid, i); | ||
write(1, buf, strlen(buf)); | ||
} | ||
} | ||
#include <stdio.h> | ||
#include <string.h> | ||
#include <sys/types.h> | ||
|
||
#define MAX_COUNT 10 | ||
#define BUF_SIZE 10 | ||
|
||
void main(void) | ||
{ | ||
pid_t pid; | ||
int i; | ||
char buf[BUF_SIZE]; | ||
|
||
fork(); | ||
pid = getpid(); | ||
for (i = 1; i <= MAX_COUNT; i++) { | ||
sprintf(buf, "This line is from pid %d, value = %d\n", pid, i); | ||
write(1, buf, strlen(buf)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,48 @@ | ||
#include <stdio.h> | ||
#include <sys/types.h> | ||
|
||
#define MAX_COUNT 5 | ||
|
||
void ChildProcess(void); /* child process prototype */ | ||
void ParentProcess(void); /* parent process prototype */ | ||
|
||
void main(void) | ||
{ | ||
pid_t pid; | ||
|
||
pid = fork(); | ||
if (pid == 0) | ||
ChildProcess(); | ||
else | ||
ParentProcess(); | ||
} | ||
|
||
void ChildProcess(void) | ||
{ | ||
int i,j; | ||
for (i = 1; i <= MAX_COUNT; i++) | ||
{ | ||
for(j=1; j<= i;j++) | ||
{ | ||
printf("%d\t",j); | ||
sleep(1); | ||
} | ||
printf("\n"); | ||
} | ||
|
||
printf(" *** Child process is done ***\n"); | ||
} | ||
|
||
void ParentProcess(void) | ||
{ | ||
int i,j; | ||
for (i = 1; i <= MAX_COUNT; i++) | ||
{ | ||
for(j=1; j<= i;j++) | ||
{ | ||
printf("%c\t",'*'); | ||
sleep(1); | ||
} | ||
printf("\n"); | ||
} | ||
} | ||
#include <stdio.h> | ||
#include <sys/types.h> | ||
|
||
#define MAX_COUNT 5 | ||
|
||
void ChildProcess(void); /* child process prototype */ | ||
void ParentProcess(void); /* parent process prototype */ | ||
|
||
void main(void) | ||
{ | ||
pid_t pid; | ||
|
||
pid = fork(); | ||
if (pid == 0) | ||
ChildProcess(); | ||
else | ||
ParentProcess(); | ||
} | ||
|
||
void ChildProcess(void) | ||
{ | ||
int i,j; | ||
for (i = 1; i <= MAX_COUNT; i++) | ||
{ | ||
for(j=1; j<= i;j++) | ||
{ | ||
printf("%d\t",j); | ||
sleep(1); | ||
} | ||
printf("\n"); | ||
} | ||
|
||
printf(" *** Child process is done ***\n"); | ||
} | ||
|
||
void ParentProcess(void) | ||
{ | ||
int i,j; | ||
for (i = 1; i <= MAX_COUNT; i++) | ||
{ | ||
for(j=1; j<= i;j++) | ||
{ | ||
printf("%c\t",'*'); | ||
sleep(1); | ||
} | ||
printf("\n"); | ||
} | ||
} |
File renamed without changes.
Oops, something went wrong.