Skip to content

Commit

Permalink
Cleaning the Bottleneck
Browse files Browse the repository at this point in the history
  • Loading branch information
NishkarshRaj committed Jun 6, 2019
1 parent 08d0a71 commit 8fea0da
Show file tree
Hide file tree
Showing 64 changed files with 760 additions and 45,610 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file removed C_Program_type_shells/0
Empty file.
Empty file removed C_Program_type_shells/24
Empty file.
Empty file removed C_Program_type_shells/5
Empty file.
Empty file removed C_Program_type_shells/6
Empty file.
Empty file removed C_Program_type_shells/61
Empty file.
File renamed without changes.
34 changes: 17 additions & 17 deletions fork/fork1.c → Forking/fork1.c
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;
}
72 changes: 36 additions & 36 deletions fork/fork2.c → Forking/fork2.c
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");
}
40 changes: 20 additions & 20 deletions fork/fork3.c → Forking/fork3.c
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));
}
}
96 changes: 48 additions & 48 deletions fork/forkassignment.c → Forking/forkassignment.c
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.
Loading

0 comments on commit 8fea0da

Please sign in to comment.