Os 236

  • Uploaded by: Haritha
  • 0
  • 0
  • August 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Os 236 as PDF for free.

More details

  • Words: 263
  • Pages: 4
Lab- Assessment-1 Name: S.Haritha Slot: L49+L50

Reg.No: 17MIS0236 Faculty: Deepa.K

1)Parent child process creation using fork( ) and exec() system call Checking the Process Identifier Assigning new task to child Providing the path name and program name to exec() Synchronizing Parent and child process using wait() Code: #include<stdio.h> #include #include<stdlib.h> #include<sys/wait.h> int main(void) { int pid; // child variable int status;//Status of the child printf("hi\n"); char *args[] = {"sai./EXEC",&status}; execl(args[0],args); printf("Executing File"); //Parent Process Identifier and with their address printf("I am the parent process and pid is : %d.\n",getpid()); printf(" I am just befeor use of fork\n"); //Assinging task to fork() pid = fork(); //Assign task to the child to print printf("here I am just after forking\n"); //Child process Identifier with their address

if (pid == -1) //checking for error { wait(&status); printf("I am waiting for the child"); } if (pid == 0) printf(" I am the child process and pid is :%d.\n", getpid()); else printf(" I am the parent process and pid is:%d./n",getpid()); }

Output:

2)Write a Program to create parent and child process. Assign the task of calculating the Fibonacci Series to parent and checking whether a number is Armstrong Number or not to Child.

Code: #include<stdio.h> #include<stdlib.h> #include<sys/types.h> #include int main() { int pid=fork(); if(pid==0) { int number; int sum=0; int rem=0; int temp; printf("enter a number"); scanf("%d",&number); temp=number; while(number!=0) { rem=number%10; sum=sum+(rem*rem*rem); number=number/10; } if(sum==temp) printf("armstrong"); else printf("no"); } else { int first=0; int second=1; int next; int c; int n; printf("Enter the number of terms\n"); scanf("%d",&n); printf("%d\n",first); printf("%d\n",second); for(c=1;c<=n;c++)

{ next=first+second; first=second; second=next; printf("%d\n",next); } } }

Output:

Related Documents

Os 236
August 2019 26
236
November 2019 15
236
December 2019 37
236
May 2020 8
Lal_kitab_1952_ 236
August 2019 26
236.pdf
December 2019 23

More Documents from "Fahriza Rizky"

Os 236
August 2019 26
Sam Tpa.docx
November 2019 44
13 Abstract
August 2019 27
Machinelearning (1).docx
November 2019 14
Abdalla2018.pdf
August 2019 22