+ All Categories
Home > Documents > Introduction to UNIX, its architecture and ... - Web viewIn UNIX, commands are submitted to the...

Introduction to UNIX, its architecture and ... - Web viewIn UNIX, commands are submitted to the...

Date post: 31-Jan-2018
Category:
Upload: nguyenkien
View: 233 times
Download: 0 times
Share this document with a friend
79
OPERATING SYSTEM LAB BACHELOR OF TECHNOLOGY IN COMPUTER SCIENCE & ENGINEERING Amity of School of Engineering & Technology Amity University UNDER THE GUIDANCE OF: SUBMITTED BY:
Transcript
Page 1: Introduction to UNIX, its architecture and ... - Web viewIn UNIX, commands are submitted to the Operating System via a shell. A shell is an environment which allows commands to be

OPERATING SYSTEM LAB

BACHELOR OF TECHNOLOGY IN COMPUTER SCIENCE & ENGINEERING

Amity of School of Engineering & Technology Amity University

UNDER THE GUIDANCE OF: SUBMITTED BY:

ASET, AUUP

Page 2: Introduction to UNIX, its architecture and ... - Web viewIn UNIX, commands are submitted to the Operating System via a shell. A shell is an environment which allows commands to be

INDEX

S.NO.

CATEGORY OF EXP.

CODE Exp.No.

NAME OF EXPERIMENT DATE OF ALLOTMENT OF EXP.

DATE OFEVALUAN

MAX.MARKS

MARKSOBT.

SIGN.OFFACULTY

1. MANDATO-RYEXP.

LR (10)

1 Introduction to UNIX, its architecture and features

1

2. 2 WRITE a program to explain all the basic general purpose UNIX commands

1

3. 3 WRITE a program to explain all the commands related to file system.

1

4. 4 WRITE a program to explain all the file handling commands.

1

5. 5 Write a program to explain all the commands related to file attributes and permissions.

1

6. 6(a)

6(b)

6(c)

Write a program to implement shell scripting for calculating factorial of a number.

Write a program to implement shell scripting for calculating area of a circle.

Write a program to implement shell scripting to find the largest number among given number.

1

Page 3: Introduction to UNIX, its architecture and ... - Web viewIn UNIX, commands are submitted to the Operating System via a shell. A shell is an environment which allows commands to be

7. 7 Write a program to implement First Come First Serve scheduling.

1

8. 8(a)

8(b)

Write a program to implement non preemptive Shortest Job First scheduling.

Write a program to implement preemptive Shortest Job First scheduling.

1

9. 9(a)

9(b)

Write a program to implement non preemptive Priority scheduling.

Write a program to implement preemptive Priority scheduling.

1

10. 10 Write a program to implement Round Robin scheduling.

1

11. Design Based Open Ended experiment

PR (10)

10

12. Viva Viva (5)

5

Page 4: Introduction to UNIX, its architecture and ... - Web viewIn UNIX, commands are submitted to the Operating System via a shell. A shell is an environment which allows commands to be

EXPERIMENT – 1

1. OBJECTIVE: Introduction to UNIX, its architecture and features

2. EQUIPMENT / SOFTWARE USED:

3. THEORY:

UNIX is an operating system which was first developed in the 1960s, and has been under constant development ever since. By operating system, we mean the suite of programs which make the computer work. It is a stable, multi-user, multi-tasking system for servers, desktops and laptops.

UNIX systems also have a graphical user interface (GUI) similar to Microsoft Windows which provides an easy to use environment. However, knowledge of UNIX is required for operations which aren't covered by a graphical program, or for when there is no windows interface available, for example, in a telnet session.

Architecture: The main concept that unites all versions of UNIX is the following four basics −

Kernel: The kernel is the heart of the operating system. It interacts with hardware and most of the tasks like memory management, tash scheduling and file management.

Shell: The shell is the utility that processes your requests. When you type in a command at your terminal, the shell interprets the command and calls the program that you want. The shell uses standard syntax for all commands. C Shell, Bourne

Name:Enrollment no: A23052141Date:

S.No. Hardware Software1. I7 Processor UNIX OS2. 16GB RAM Microsoft Word3. Keyboard TELNET4. Mouse SNIPPING TOOL5. Monitor6. Printer

Page 5: Introduction to UNIX, its architecture and ... - Web viewIn UNIX, commands are submitted to the Operating System via a shell. A shell is an environment which allows commands to be

Shell and Korn Shell are most famous shells which are available with most of the Unix variants.

Commands and Utilities: There are various command and utilities which you would use in your day to day activities. cp, mv, cat andgrep etc. are few examples of commands and utilities. There are over 250 standard commands plus numerous others provided through 3rd party software. All the commands come along with various optional options.

Files and Directories: All data in UNIX is organized into files. All files are organized into directories. These directories are organized into a tree-like structure called the filesystem.

Features: It is written in high-level language, 'C' making it easy to port to different configurations.

It is a good operating system, especially, for programs. UNIX programming environment is unusually rich and productive. It provides features that allow complex programs to be built from simpler programs.

It uses a hierarchical file system that allows easy maintenance and efficient implementation.

It uses a consistent format for files, the byte stream, making application programs easier to write.

It is a multi-user, multiprocess system. Each user can execute several processes simultaneously.

It hides the machine architecture from the user, making it easier to write programs that run on different hardware implementation.

ARCHITECTURE OF OPERATING SYSTEM

Page 6: Introduction to UNIX, its architecture and ... - Web viewIn UNIX, commands are submitted to the Operating System via a shell. A shell is an environment which allows commands to be

pwd: The pwd command reports the full path to the current working directory.The current directory is the directory in which a user is currently operating while using a command line interface. Syntax: pwd

ls: Unix System has large number of files that controls functioning ,and the users also create files on their own. These files are arranged in separate folders called directories. This command list the contents of the current directory

4. PROCEDURE:

Telnet 10.0.2.26

login : asodl1

password : aspdl1

pwd: pwd

ls: ls

5. OUTPUT:

6. OBSERVATIONS AND DISCUSSIONS:The output from the above code can be shown using above snapshot

Page 7: Introduction to UNIX, its architecture and ... - Web viewIn UNIX, commands are submitted to the Operating System via a shell. A shell is an environment which allows commands to be

7. RESULT:The program is successfully written and created in Unix OS.

Faculty Name: Mrs Arunima JaiswalSignature:Date:

INTERNAL EVALUATION FOR MANDATORY EXPERIMENT

Criteria Total Marks Marks Obtained Comments

Concept (A) 2

Implementation (B) 2

Performance (C) 2

Total 6

Page 8: Introduction to UNIX, its architecture and ... - Web viewIn UNIX, commands are submitted to the Operating System via a shell. A shell is an environment which allows commands to be

EXPERIMENT-2

1. OBJECTIVE: Write a program to explain all the basic general purpose UNIX commands

2. EQUIPMENT / SOFTWARE USED:

3. THEORY:

cal: It is a handy tool that we invoke anytime to see the calendar of any specific mont, or a complete year for ex: to see the calendar for the month of June 2013 provide the month number and the year as two arguments.sSyntax: $ cal 6 2013

date: It is a valid command that displays both date and time . The date command instructs the machine to display the current date and time.

echo: echo is a built-in command in C shells that writes its arguments to standard output.syntax :echo [option(s)] [string(s)]

printf: printf prints a formatted string to the standard output. Its roots are in the C programming language, which uses a function by the same name. It is a handy way to produce precisely-formatted output from numerical or textual arguments.

bc: bc is a language that supports arbitrary-precision numbers, meaning that it delivers accurate results regardless of how large (or very very small) the numbers are.It has an interactive mode, accepting input from the terminal and providing calculations on request. As a language, its syntax is similar to the C programming language.

Name:Enrollment no: A23052141Date:

S.No. Hardware Software1. I7 Processor UNIX OS2. 16GB RAM Microsoft Word3. Keyboard TELNET4. Mouse SNIPPING TOOL5. Monitor6. Printer

Page 9: Introduction to UNIX, its architecture and ... - Web viewIn UNIX, commands are submitted to the Operating System via a shell. A shell is an environment which allows commands to be

script: script makes a typescript of everything printed on your terminal. It is useful for users who need a hardcopy record of an interactive session as proof of work done, as the typescript file can be printed out later with lpr.

password: Along with your username, your password grants you access to the system.

who: Displays the name of the machine and time of login.

uname: Print certain system information. If no OPTION is specified, uname assumes the -s option.

tty: Print the file name of the terminal connected to standard input.

sty: stty displays or changes the characteristics of the terminal.

4. PROCEDURE:

date: date date +%d date+%m date+%h date+%y

cal: cal 2016 cal cal jan

who: who

echo: echo”data”>files11.txt cat files11.txt 5. OUTPUT:

Page 10: Introduction to UNIX, its architecture and ... - Web viewIn UNIX, commands are submitted to the Operating System via a shell. A shell is an environment which allows commands to be

6. OBSERVATIONS AND DISCUSSIONS:The output from the above code can be shown using above snapshot

7. RESULT:The program is successfully written and created using Unix OS

Faculty Name: Mrs Arunima JaiswalSignature:Date:

Page 11: Introduction to UNIX, its architecture and ... - Web viewIn UNIX, commands are submitted to the Operating System via a shell. A shell is an environment which allows commands to be

INTERNAL EVALUATION FOR MANDATORY EXPERIMENTS

Criteria Total Marks Marks Obtained Comments

Concept (A) 2

Implementation (B) 2

Performance (C) 2

Total 6

Page 12: Introduction to UNIX, its architecture and ... - Web viewIn UNIX, commands are submitted to the Operating System via a shell. A shell is an environment which allows commands to be

EXPERIMENT – 3

1. OBJECTIVE: Write a program to explain all the commands related to file system.

2. EQUIPMENT / SOFTWARE USED:

3. THEORY:

pwd:Displays the current working directory.Syntax: $ pwd

cd: This command is used to change the directory.Syntax: $ cd

rmdir: This command is used to remove directories.Syntax: $ rmdir directory_name.

mkdir : Directories are made with the help of mkdir command. The command is followed by the name of the directories created A directory path is under the current directory like, $ mkdir directory_name.

ls: Unix System has large number of files that controls functioning ,and the users also create files on their own. These files are arranged in separate folders called directories. This command list the contents of the current directory

ps: Every command that we run gives rise to a process , and the shell is a process as well . To view all processes that we are responsible for creating, we run ps command.Syntax: $ ps .

Name:Enrollment no: A23052141Date:

S.No. Hardware Software1. I7 Processor UNIX OS2. 16GB RAM Microsoft Word3. Keyboard TELNET4. Mouse SNIPPING TOOL5. Monitor6. Printer

Page 13: Introduction to UNIX, its architecture and ... - Web viewIn UNIX, commands are submitted to the Operating System via a shell. A shell is an environment which allows commands to be

grep: The grep command allows you to search one file or multiple files for lines that contain a pattern

4. PROCEDURE:

pwd: pwdcd: cd apoorvarmdir: rmdir apoorvamkdir: mkdir apoorvals: lsps: psgrep:

5. OUTPUT:

6. OBSERVATIONS AND DISCUSSIONS:The output from the above code can be shown using above snapshot

7. RESULT:The program is successfully written and created using Unix OS

Faculty Name: Mrs Arunima JaiswalSignature:Date:

Page 14: Introduction to UNIX, its architecture and ... - Web viewIn UNIX, commands are submitted to the Operating System via a shell. A shell is an environment which allows commands to be

INTERNAL EVALUATION FOR MANDATORY EXPERIMENTS

Criteria Total Marks Marks Obtained Comments

Concept (A) 2

Implementation (B) 2

Performance (C) 2

Total 6

Page 15: Introduction to UNIX, its architecture and ... - Web viewIn UNIX, commands are submitted to the Operating System via a shell. A shell is an environment which allows commands to be

EXPERIMENT – 4

1. OBJECTIVE: Write a program to explain all the file handling commands.

2. EQUIPMENT / SOFTWARE USED:

3. THEORY:

cat: cat stands for ”concatenate” . It reads data from files, and outputs their contents. It is the simplest way to display the contents of file at the command line.

cp: Copies one file to another. Syntax: cp [file 1] [file 2 .

rm: Removes a file . Syntax: rm [file 1] [file 2].

mv: Renames a file .Syntax: mv [oldfilename] [newfilename].

file: The file command tests each argument in an attempt to classify it. There are three sets of tests, performed in this order: filesystem tests, magic tests, and language tests. The first test that succeeds causes the file type to be printed.

wc: counts the number of lines, words, bytes of file. Syntax: wc [bytes] [characters] [lines] [files…].Ex:$ wc myfile.

od: od dumps files in octal and other formats.

cmp: To know whether two files are identical so one of them can be deleted . Syntax: $ cmp [file1] [file2]

Name:Enrollment no: A23052141Date:

S.No. Hardware Software1. I7 Processor UNIX OS2. 16GB RAM Microsoft Word3. Keyboard TELNET4. Mouse SNIPPING TOOL5. Monitor6. Printer

Page 16: Introduction to UNIX, its architecture and ... - Web viewIn UNIX, commands are submitted to the Operating System via a shell. A shell is an environment which allows commands to be

diff: diff analyzes two files and prints the lines that are different. Essentially, it outputs a set of instructions for how to change one file in order to make it identical to the second file.

tar: The tar program is used to create, maintain, modify, and extract files that are archived in the tar format.

zip: The zip program is used to package and compress files.

unzip: The unzip command lists, extracts, and tests compressed files in a ZIP archive.

4. PROCEDURE:

cat: cat>>file177 hello everyone!

cp: mkdir 177 cat>file 177 this is a file cat>file 277 cp file 177 277 cat file 277

rm: mkdir d177 cd d177 touch file177 cat>>file177 hello everyone! rm file 177 cat file177

mv: mkdir4177 touch file1 cat>file1 mv file1 file 4177 cat file 4177

wc: cat>myunixfile.txt this is apoorva i love my os lab i am making my first filewc –w myunixfile.txtwc –l myunixfile.txt

cmp: mkdir s177 cat>file 177 cp file177 file 277 cat file 277 cmp file 177 file 277 cat file 277

Page 17: Introduction to UNIX, its architecture and ... - Web viewIn UNIX, commands are submitted to the Operating System via a shell. A shell is an environment which allows commands to be

5. OUTPUT:

6. OBSERVATIONS AND DISCUSSIONS:The output from the above code can be shown using above snapshot

7. RESULT:The program is successfully written and created using Unix OS

Faculty Name: Mrs Arunima JaiswalSignature:Date

INTERNAL EVALUATION FOR MANDATORY EXPERIMENTS

Page 18: Introduction to UNIX, its architecture and ... - Web viewIn UNIX, commands are submitted to the Operating System via a shell. A shell is an environment which allows commands to be

Criteria Total Marks Marks Obtained Comments

Concept (A) 2

Implementation (B) 2

Performance (C) 2

Total 6

Page 19: Introduction to UNIX, its architecture and ... - Web viewIn UNIX, commands are submitted to the Operating System via a shell. A shell is an environment which allows commands to be

EXPERIMENT – 5

1. OBJECTIVE: Write a program to explain all the commands related to file attributes and permissions.

2. EQUIPMENT / SOFTWARE USED:

3. THEORY:

Ls-l: Lists the contents of a directory.

chmod: This command is used to change the mode., it only changes the permission specified in the comman line and leaves othr permissions unchanged.s

File ownership:

File permission:

-d:4. PROCEDURE:

5. OUTPUT:

Name:Enrollment no: A23052141Date:

S.No. Hardware Software1. I7 Processor UNIX OS2. 16GB RAM Microsoft Word3. Keyboard TELNET4. Mouse SNIPPING TOOL5. Monitor6. Printer

Page 20: Introduction to UNIX, its architecture and ... - Web viewIn UNIX, commands are submitted to the Operating System via a shell. A shell is an environment which allows commands to be

6. OBSERVATIONS AND DISCUSSIONS:The output from the above code can be shown using above snapshot

7. RESULT:

The program is successfully written and created using Unix OS

Faculty Name: Mrs Arunima JaiswalSignature:Date:

INTERNAL EVALUATION FOR MANDATORY EXPERIMENTS

Page 21: Introduction to UNIX, its architecture and ... - Web viewIn UNIX, commands are submitted to the Operating System via a shell. A shell is an environment which allows commands to be

Criteria Total Marks Marks Obtained Comments

Concept (A) 2

Implementation (B) 2

Performance (C) 2

Total 6

Page 22: Introduction to UNIX, its architecture and ... - Web viewIn UNIX, commands are submitted to the Operating System via a shell. A shell is an environment which allows commands to be

EXPERIMENT – 6(A)

1.OBJECTIVE: Write a program to implement shell scripting for calculating factorial of a number.

2. EQUIPMENT / SOFTWARE USED:

3. THEORY:

In UNIX, commands are submitted to the Operating System via a shell. A shell is an environment which allows commands to be issued, and also includes facilities to control input and output, and programming facilities to allow complex sets of actions to be performed. Whenever you type commands at the prompt in Unix, you are actually communicating interactively with a shell.

In addition to typing commands directly to the shell, you can place them in a file (which must be given execute permission), and then run the file. A file containing UNIX shell commands is known as a script (or shell script). Executing the script is equivalent to typing the commands within it.

The Unix shells are actually quite sophisticated programming languages in their own right: there are entire books devoted to programming in them. Together with the large number of special utility programs which are provided as standard, scripts make Unix an extremely powerful operating system.

Scripts are interpreted rather than compiled, which means that the computer must translate them each time it runs them: they are thus less efficient than programs written in (for example) C. However, they are extremely good where you want to use Operating System facilities

Name:Enrollment no: A23052141Date:

S.No. Hardware Software1. I7 Processor UNIX OS2. 16GB RAM Microsoft Word3. Keyboard TELNET4. Mouse SNIPPING TOOL5. Monitor6. Printer

Page 23: Introduction to UNIX, its architecture and ... - Web viewIn UNIX, commands are submitted to the Operating System via a shell. A shell is an environment which allows commands to be

4. PROCEDURE:

i=1f=1echo "Enter the Number whose Factorial needs to be Calculated :"read nwhile [ $i -le $n ]dof=`expr $f \* $i`i=`expr $i + 1`doneecho "The factorial of $n is":$f

5. OUTPUT:

6. OBSERVATIONS AND DISCUSSIONS:The output from the above code can be shown using above snapshot

7. RESULT:

The program is successfully written and created using Unix OS

Faculty Name: Mrs Arunima JaiswalSignature:Date:

Page 24: Introduction to UNIX, its architecture and ... - Web viewIn UNIX, commands are submitted to the Operating System via a shell. A shell is an environment which allows commands to be

EXPERIMENT – 6(B)

1.OBJECTIVE: Write a program to implement shell scripting for calculating area of a circle.

2. EQUIPMENT / SOFTWARE USED:

3. THEORY:

In UNIX, commands are submitted to the Operating System via a shell. A shell is an environment which allows commands to be issued, and also includes facilities to control input and output, and programming facilities to allow complex sets of actions to be performed. Whenever you type commands at the prompt in Unix, you are actually communicating interactively with a shell.

In addition to typing commands directly to the shell, you can place them in a file (which must be given execute permission), and then run the file. A file containing UNIX shell commands is known as a script (or shell script). Executing the script is equivalent to typing the commands within it.

The Unix shells are actually quite sophisticated programming languages in their own right: there are entire books devoted to programming in them. Together with the large number of special utility programs which are provided as standard, scripts make Unix an extremely powerful operating system.

Scripts are interpreted rather than compiled, which means that the computer must translate them each time it runs them: they are thus less efficient than programs written in (for example) C. However, they are extremely good where you want to use Operating System facilities

4. PROCEDURE:

Name:Enrollment no: A23052141Date:

S.No. Hardware Software1. I7 Processor UNIX OS2. 16GB RAM Microsoft Word3. Keyboard TELNET4. Mouse SNIPPING TOOL5. Monitor6. Printer

Page 25: Introduction to UNIX, its architecture and ... - Web viewIn UNIX, commands are submitted to the Operating System via a shell. A shell is an environment which allows commands to be

echo -n "Enter the radius of a Circle : "read r# use formula to get itarea=$(echo "scale=2;3.14 * ($r * $r)" | bc)d=$(echo "scale=2;2 * $r"|bc)echo "Area of circle is $area"

5. OUTPUT:

6. OBSERVATIONS AND DISCUSSIONS:The output from the above code can be shown using above snapshot

7. RESULT:

The program is successfully written and created using Unix OS

Faculty Name: Mrs Arunima JaiswalSignature:Date:

Page 26: Introduction to UNIX, its architecture and ... - Web viewIn UNIX, commands are submitted to the Operating System via a shell. A shell is an environment which allows commands to be

EXPERIMENT – 6(C)

1.OBJECTIVE: Write a program to implement shell scripting to find the largest number among given number.

2. EQUIPMENT / SOFTWARE USED:

3. THEORY:

In UNIX, commands are submitted to the Operating System via a shell. A shell is an environment which allows commands to be issued, and also includes facilities to control input and output, and programming facilities to allow complex sets of actions to be performed. Whenever you type commands at the prompt in Unix, you are actually communicating interactively with a shell.

In addition to typing commands directly to the shell, you can place them in a file (which must be given execute permission), and then run the file. A file containing UNIX shell commands is known as a script (or shell script). Executing the script is equivalent to typing the commands within it.

The Unix shells are actually quite sophisticated programming languages in their own right: there are entire books devoted to programming in them. Together with the large number of special utility programs which are provided as standard, scripts make Unix an extremely powerful operating system.

Scripts are interpreted rather than compiled, which means that the computer must translate them each time it runs them: they are thus less efficient than programs written in (for example) C. However, they are extremely good where you want to use Operating System facilities

Name:Enrollment no: A23052141Date:

S.No. Hardware Software1. I7 Processor UNIX OS2. 16GB RAM Microsoft Word3. Keyboard TELNET4. Mouse SNIPPING TOOL5. Monitor6. Printer

Page 27: Introduction to UNIX, its architecture and ... - Web viewIn UNIX, commands are submitted to the Operating System via a shell. A shell is an environment which allows commands to be

4. PROCEDURE:

echo Enter 3 numbers with spaces in betweenread a b cl=$aif [ $b -gt $l ]thenl=$bfiif [ $c -gt $l ]thenl=$cfiecho Lagest of $a $b $c is $l

5. OUTPUT:

6. OBSERVATIONS AND DISCUSSIONS:The output from the above code can be shown using above snapshot

7. RESULT:

The program is successfully written and created using Unix OS

Faculty Name: Mrs Arunima JaiswalSignature:Date:

Page 28: Introduction to UNIX, its architecture and ... - Web viewIn UNIX, commands are submitted to the Operating System via a shell. A shell is an environment which allows commands to be

INTERNAL EVALUATION FOR MANDATORY EXPERIMENT

Criteria Total Marks Marks Obtained Comments

Concept (A) 2

Implementation (B) 2

Performance (C) 2

Total 6

Page 29: Introduction to UNIX, its architecture and ... - Web viewIn UNIX, commands are submitted to the Operating System via a shell. A shell is an environment which allows commands to be

EXPERIMENT – 7

1. OBJECTIVE: Write a program to implement First Come First Serve scheduling.

2. EQUIPMENT / SOFTWARE USED:

3. THEORY:

First-Come-First-Served algorithm is the simplest scheduling algorithm is the simplest scheduling algorithm. Processes are dispatched according to their arrival time on the ready queue. Being a non preemptive discipline, once a process has a CPU, it runs to completion. The FCFS scheduling is fair in the formal sense or human sense of fairness but it is unfair in the sense that long jobs make short jobs wait and unimportant jobs make important jobs wait.

FCFS is more predictable than most of other schemes since it offers time. FCFS scheme is not useful in scheduling interactive users because it cannot guarantee good response time. The code for FCFS scheduling is simple to write and understand. One of the major drawback of this scheme is that the average time is often quite long.

The First-Come-First-Served algorithm is rarely used as a master scheme in modern operating systems but it is often embedded within other schemes

4. PROCEDURE:

#include<stdio.h>#include<alloc.h>#include<process.h>#include<conio.h>

struct node{float wt;

Name:Enrollment no: A23052141Date:

S.No. Hardware Software1. I7 Processor UNIX OS2. 16GB RAM Microsoft Word3. Keyboard TELNET4. Mouse SNIPPING TOOL5. Monitor6. Printer

Page 30: Introduction to UNIX, its architecture and ... - Web viewIn UNIX, commands are submitted to the Operating System via a shell. A shell is an environment which allows commands to be

float at;int n;float bt;struct node*next;};

void main(){int process[5];float bb,ata1,w1,ata,w,ata2,w2;int ch,na,p,i,j;struct node *start;struct node *save,*s,*q;struct node *ptr,*newnode; start=NULL;while(1){printf("\n Enter choice:1.Enter the process\n2.FCFS\n3.Exit");scanf("%d",&ch);switch(ch) { case 1: newnode=(struct node*)malloc(sizeof(struct node)); printf("\n Enter process name:P"); scanf("%d",&na); printf("\n Enter burst time:"); scanf("%f",&bb); newnode->next=NULL; newnode->n=na; newnode->bt=bb; printf("%d",newnode->n); if(start==NULL) { start=newnode; save=start; } else { save->next=newnode; save=newnode;} break;

case 2: ata2=0,w2=0; p=0; for(ptr=start;ptr!=NULL;ptr=ptr->next) { printf("\tP%d",ptr->n); p++; } s=start; for(i=1;i<=p;i++) { ata1=0,w1=0;

Page 31: Introduction to UNIX, its architecture and ... - Web viewIn UNIX, commands are submitted to the Operating System via a shell. A shell is an environment which allows commands to be

q=start; for(j=1;j<i;j++) { ata1=ata1+q->bt; w1=w1+q->bt; q=q->next; } s->at=ata1+s->bt; s->wt=w1; printf("At%d:%f\tWT%d:%f",i,s->at,i,s->wt); s=s->next; } for(ptr=start;ptr!=NULL;ptr=ptr->next) { ata2=ata2+ptr->at; w2=w2+ptr->wt; } w=w2/p; ata=ata2/p;printf("Average waitin time:%f and turn around time:%f",w,ata);break;

case 3: exit(0);getch();}}}

5. OUTPUT:

Page 32: Introduction to UNIX, its architecture and ... - Web viewIn UNIX, commands are submitted to the Operating System via a shell. A shell is an environment which allows commands to be

6. OBSERVATIONS AND DISCUSSIONS:

Page 33: Introduction to UNIX, its architecture and ... - Web viewIn UNIX, commands are submitted to the Operating System via a shell. A shell is an environment which allows commands to be

The output from the above code can be shown using above snapshot

7. RESULT:

The program is successfully written and created using Unix OS

Faculty Name: Mrs Arunima JaiswalSignature:Date:

Page 34: Introduction to UNIX, its architecture and ... - Web viewIn UNIX, commands are submitted to the Operating System via a shell. A shell is an environment which allows commands to be

INTERNAL EVALUATION FOR MANDATORY EXPERIMENTS

EXPERIMENT – 8(A)

Criteria Total Marks Marks Obtained Comments

Concept (A) 2

Implementation (B) 2

Performance (C) 2

Total 6

Page 35: Introduction to UNIX, its architecture and ... - Web viewIn UNIX, commands are submitted to the Operating System via a shell. A shell is an environment which allows commands to be

1.OBJECTIVE: Write a program to implement non preemptive Shortest Job First scheduling.

2. EQUIPMENT / SOFTWARE USED:

3. THEORY:

A non-preemptive Shortest-Job-First (SJF) is a discipline in which waiting job (or process) with the smallest estimated run-time-to-completion is run next. In other words, when CPU is available, it is assigned to the process that has smallest next CPU burst.

The SJF scheduling is especially appropriate for batch jobs for which the run times are known in advance. Since the SJF scheduling algorithm gives the minimum average time for a given set of processes, it is probably optimal.

The SJF algorithm favors short jobs (or processors) at the expense of longer ones

4. PROCEDURE:

#include<stdio.h>//#include<alloc.h>#include<process.h>#include<conio.h>

struct node{float wt;float at;

Name:Enrollment no: A23052141Date:

S.No. Hardware Software1. I7 Processor UNIX OS2. 16GB RAM Microsoft Word3. Keyboard TELNET4. Mouse SNIPPING TOOL5. Monitor6. Printer

Page 36: Introduction to UNIX, its architecture and ... - Web viewIn UNIX, commands are submitted to the Operating System via a shell. A shell is an environment which allows commands to be

int n;float bt;struct node*next;float ta;}; main(){int process[5];float bb,ta1,w1,ta,w,ta2,w2,at,at1,at2,m,u;int ch,na,p,i,j,n;struct node *start;struct node *save,*s,*q,*r,*t;struct node *ptr,*newnode; start=NULL;while(1){printf("\n Enter choice:\n1.Enter process\n2.SJFS\n3.Exit\n");scanf("%d",&ch);switch(ch){case 1:newnode=(struct node*)malloc(sizeof(struct node));

printf("\n Enter process name:P");scanf("%d",&na);printf("\n Enter burst time:");scanf("%f",&bb);printf("\n Enter arrival time:");scanf("%f",&at);newnode->next=NULL;newnode->n=na;newnode->bt=bb;newnode->at=at;

if(start==NULL){start=newnode;save=start;}else{save->next=newnode;save=newnode;}break;

case 2: ta2=0,w2=0; p=0;for(ptr=start;ptr!=NULL;ptr=ptr->next){p++;}printf("\n Process Burst time Arrival Time");

Page 37: Introduction to UNIX, its architecture and ... - Web viewIn UNIX, commands are submitted to the Operating System via a shell. A shell is an environment which allows commands to be

r=start;for(i=1;i<=p;i++){t=r;for(j=i;j<=p;j++){if((r->bt>t->bt)) { m=r->bt; r->bt=t->bt; t->bt=m; u=r->at; r->at=t->at; t->at=u;n=r->n; r->n=t->n; t->n=n;}t=t->next;}r=r->next;}

for(ptr=start;ptr!=NULL;ptr=ptr->next){ printf("\n P%d %f %f", ptr->n,ptr->bt,ptr->at);}s=start;for(i=1;i<=p;i++){ta1=0,w1=0; q=start;for(j=1;j<i;j++){ta1=ta1+q->bt;w1=w1+q->bt;q=q->next;}s->ta=ta1+s->bt-s->at;s->wt=w1;s=s->next;}/*r=start;for(i=1;i<=p;i++){t=r;for(j=i;j<=p;j++){if(r->bt>t->bt){m=r->bt;r->bt=t->bt;

Page 38: Introduction to UNIX, its architecture and ... - Web viewIn UNIX, commands are submitted to the Operating System via a shell. A shell is an environment which allows commands to be

t->bt=m;n=r->n;r->n=t->n;t->n=n;}t=t->next;}r=r->next;}printf("\n Sequence of Execution");for(ptr=start;ptr!=NULL;ptr=ptr->next){printf("\tP%d",ptr->n);}s=start;for(i=1;i<=p;i++){ ata1=0,w1=0; q=start;for(j=1;j<i;j++){ata1=ata1+q->bt;w1=w1+q->bt;q=q->next;}s->at=ata1+s->bt;s->wt=w1;printf("\nP%d: wt:%f, ta :%f",i,s->wt,s->at);s=s->next;}*/

for(ptr=start;ptr!=NULL;ptr=ptr->next){ ta2=ta2+ptr->ta;w2=w2+ptr->wt;

} w=w2/p; ta=ta2/p; printf("\n Avg waitin time:%f \nTurn around time:%f",w,ta);

printf("\n");break;

case 3:exit(0);

getch();}}}

5. OUTPUT:

Page 39: Introduction to UNIX, its architecture and ... - Web viewIn UNIX, commands are submitted to the Operating System via a shell. A shell is an environment which allows commands to be
Page 40: Introduction to UNIX, its architecture and ... - Web viewIn UNIX, commands are submitted to the Operating System via a shell. A shell is an environment which allows commands to be

6. OBSERVATIONS AND DISCUSSIONS:The output from the above code can be shown using above snapshot

7. RESULT:

The program is successfully written and created using Unix OS

Faculty Name: Mrs Arunima JaiswalSignature:Date:

EXPERIMENT – 8(B)

Page 41: Introduction to UNIX, its architecture and ... - Web viewIn UNIX, commands are submitted to the Operating System via a shell. A shell is an environment which allows commands to be

1.OBJECTIVE: Write a program to implement preemptive Shortest Job First scheduling.

2. EQUIPMENT / SOFTWARE USED:

3. THEORY:

A preemptive Shortest-Job-First (SJF) is a discipline in which waiting job (or process) which is currently in execution , runs until it complete  or a new process is added in the cpu Scheduler that requires smaller amount of  time for execution. Then the running process is preemepted and new process is allocated to CPU. It is also known as shortest remaining time first(SRTF).

4. PROCEDURE:#include<stdio.h>//#include<alloc.h>#include<process.h>#include<conio.h>

struct node{float wt;float at;int n;float bt;struct node*next;float ta;}; main(){int process[5];float bb,ta1,w1,ta,w,ta2,w2,at,at1,at2,m,u;

Name:Enrollment no: A23052141Date:

S.No. Hardware Software1. I7 Processor UNIX OS2. 16GB RAM Microsoft Word3. Keyboard TELNET4. Mouse SNIPPING TOOL5. Monitor6. Printer

Page 42: Introduction to UNIX, its architecture and ... - Web viewIn UNIX, commands are submitted to the Operating System via a shell. A shell is an environment which allows commands to be

int ch,na,p,i,j,n;struct node *start;struct node *save,*s,*q,*r,*t;struct node *ptr,*newnode; start=NULL;while(1){printf("\n Enter choice:\n1.Enter process\n2.SJFS\n3.Exit\n");scanf("%d",&ch);switch(ch){case 1:newnode=(struct node*)malloc(sizeof(struct node));

printf("\n Enter process name:P");scanf("%d",&na);printf("\n Enter burst time:");scanf("%f",&bb);printf("\n Enter arrival time:");scanf("%f",&at);

newnode->next=NULL;newnode->n=na;newnode->bt=bb;newnode->at=at;

if(start==NULL){start=newnode;save=start;}else{save->next=newnode;save=newnode;}break;

case 2: ta2=0,w2=0; p=0;for(ptr=start;ptr!=NULL;ptr=ptr->next){p++;// printf("\n no of processes%d",p);}printf("\n Process Burst time Arrival Time");r=start;for(i=1;i<=p;i++){

t=r;for(j=i;j<=p;j++){// printf("Hello");

Page 43: Introduction to UNIX, its architecture and ... - Web viewIn UNIX, commands are submitted to the Operating System via a shell. A shell is an environment which allows commands to be

//printf("\n 1st P%d n 2nd P%d ",r->n,t->n);//printf("\n compare %f",(r->bt<t->bt)?r->bt:t->bt);if((r->bt>t->bt)) //&&(r->at<t->at)){ //printf("\n P%d %f %f",r->n,r->bt,r->at);

r->bt=r->bt-t->at;printf("\nP%d %f",r->n,r->bt); if(r->bt>t->bt) r->ta=t->at; t->ta=t->at;t->wt=t->bt; m=r->bt; r->bt=t->bt; t->bt=m;

u=r->at; r->at=t->at; t->at=u;//printf("\nThe new at for P%d:%f::%f",t->n,r->at,t->at);

n=r->n; r->n=t->n; t->n=n;}//else//r->bt=r->bt-t->at;t=t->next;}r=r->next;}for(ptr=start;ptr!=NULL;ptr=ptr->next){ printf("\n P%d %f %f", ptr->n,ptr->bt,ptr->at);

} s=start;for(i=1;i<=p;i++){

ta1=0,w1=0; q=start;for(j=1;j<i;j++){ta1=ta1+q->bt;w1=w1+q->bt;//printf("ta%f:",ta1);q=q->next;}//printf(" s->ta :%f, s->bt:%f , s->at:%f",s->ta,s->bt,s->at);//if( s->ta!=0.0)

Page 44: Introduction to UNIX, its architecture and ... - Web viewIn UNIX, commands are submitted to the Operating System via a shell. A shell is an environment which allows commands to be

//{s->ta=s->ta+ta1+s->bt-s->at;}//else{s->ta=ta1+s->bt-s->at;//}//if(s->wt!=0.0)//{s->wt=s->wt;}//elses->wt=w1;//printf("\nP%d: wt:%f, ta :%f",s->n,s->wt,s->ta);

s=s->next;}/*r=start;for(i=1;i<=p;i++){

t=r;for(j=i;j<=p;j++){if(r->bt>t->bt){m=r->bt;r->bt=t->bt;t->bt=m;n=r->n;r->n=t->n;t->n=n;}t=t->next;}r=r->next;}printf("\n Sequence of Execution");for(ptr=start;ptr!=NULL;ptr=ptr->next){printf("\tP%d",ptr->n);} s=start;for(i=1;i<=p;i++){ ata1=0,w1=0; q=start;for(j=1;j<i;j++){ata1=ata1+q->bt;w1=w1+q->bt;q=q->next;}s->at=ata1+s->bt;s->wt=w1;printf("\nP%d: wt:%f, ta :%f",i,s->wt,s->at);

Page 45: Introduction to UNIX, its architecture and ... - Web viewIn UNIX, commands are submitted to the Operating System via a shell. A shell is an environment which allows commands to be

s=s->next;}*/for(ptr=start;ptr!=NULL;ptr=ptr->next){ ta2=ta2+ptr->ta;w2=w2+ptr->wt;

} w=w2/p; ta=ta2/p; printf("\n Avg waitin time:%f \nTurn around time:%f",w,ta);

printf("\n");break;case 3:exit(0);getch();}}}

5. OUTPUT:

Page 46: Introduction to UNIX, its architecture and ... - Web viewIn UNIX, commands are submitted to the Operating System via a shell. A shell is an environment which allows commands to be

6. OBSERVATIONS AND DISCUSSIONS:The output from the above code can be shown using above snapshot

7. RESULT:

The program is successfully written and created using Unix OS

Faculty Name: Mrs Arunima JaiswalSignature:Date:

Page 47: Introduction to UNIX, its architecture and ... - Web viewIn UNIX, commands are submitted to the Operating System via a shell. A shell is an environment which allows commands to be

INTERNAL EVALUATION FOR MANDATORY EXPERIMENTS

Criteria Total Marks Marks Obtained Comments

Concept (A) 2

Implementation (B) 2

Performance (C) 2

Total 6

Page 48: Introduction to UNIX, its architecture and ... - Web viewIn UNIX, commands are submitted to the Operating System via a shell. A shell is an environment which allows commands to be

EXPERIMENT – 9(A)

1.OBJECTIVE: Write a program to implement non preemptive Priority scheduling.

2. EQUIPMENT / SOFTWARE USED:

3. THEORY:

In Priority scheduling Each process is assigned a priority. Process with highest priority is to be executed first and so on.Processes with same priority are executed on first come first serve basis.Priority can be decided based on memory requirements, time requirements or any other resource requirement. A non-preemptive priority algorithm will simply put the new process at the head of the ready queue.

4. PROCEDURE:

#include<stdio.h>#include<process.h>#include<conio.h>

struct node{float wt;float at;int n;float bt;struct node*next;int pr; float ta;};

Name: Anoushka PradhanEnrollment no: A2305214187Date:

S.No. Hardware Software1. I7 Processor UNIX OS2. 16GB RAM Microsoft Word3. Keyboard TELNET4. Mouse SNIPPING TOOL5. Monitor6. Printer

Page 49: Introduction to UNIX, its architecture and ... - Web viewIn UNIX, commands are submitted to the Operating System via a shell. A shell is an environment which allows commands to be

main(){int process[5];float bb,ta1,w1,ta,w,ta2,w2,at,m,u;int ch,na,p,i,j,n,ty;struct node *start;struct node *save,*s,*q,*r,*t;struct node *ptr,*newnode; start=NULL;while(1){printf("\n Enter choice:\n1.Enter process\n2.Priority \n3.Exit\n");scanf("%d",&ch);switch(ch){case 1:newnode=(struct node*)malloc(sizeof(struct node));

printf("\n Enter process name:P");scanf("%d",&na);printf("\n Enter burst time:");scanf("%f",&bb);printf("\n Enter the priority of process:");scanf("%d",&ty);printf("\n Enter the arrival time");scanf("%f",&at);

newnode->next=NULL;newnode->n=na;newnode->bt=bb;newnode->pr=ty;newnode->at=at;

if(start==NULL){start=newnode;save=start;}else{save->next=newnode;save=newnode;}break;

case 2: ta2=0,w2=0; p=0;for(ptr=start;ptr!=NULL;ptr=ptr->next){p++;}r=start;

Page 50: Introduction to UNIX, its architecture and ... - Web viewIn UNIX, commands are submitted to the Operating System via a shell. A shell is an environment which allows commands to be

for(i=1;i<=p;i++){

t=r;for(j=i;j<=p;j++){if(((r->pr>t->pr)&&(r->at>t->at))||((r->pr>t->pr)&&(r->at==t->at))||((r->pr>t->pr)&&(r->at<t->at))){m=r->bt;r->bt=t->bt;t->bt=m;u=r->at;r->at=t->at;t->at=u;//printf("The new wt for P%d:%f",t->n,t->wt);

n=r->n;r->n=t->n;t->n=n;

}t=t->next;}r=r->next;}

printf("\n Process BurstTime ArrivalTime");for(ptr=start;ptr!=NULL;ptr=ptr->next){printf("\n P%d %f %f ",ptr->n,ptr->bt,ptr->at);} s=start;for(i=1;i<=p;i++){

ta1=0,w1=0; q=start;for(j=1;j<i;j++){ta1=ta1+q->bt;w1=w1+q->bt;

q=q->next;}if(s==start && s->at!=0){s->at=0;}s->ta=ta1+s->bt-s->at;s->wt=w1;

Page 51: Introduction to UNIX, its architecture and ... - Web viewIn UNIX, commands are submitted to the Operating System via a shell. A shell is an environment which allows commands to be

//printf("\nP%d: wt:%f, ta :%f",s->n,s->wt,s->ta);

s=s->next;}

for(ptr=start;ptr!=NULL;ptr=ptr->next){ ta2=ta2+ptr->ta;w2=w2+ptr->wt;

}w=w2/p;ta=ta2/p;printf("\nAvg waitin time:%f \nTurn around time:%f",w,ta);printf("\n");break;

case 3:exit(0);

getch();}

5. OUTPUT:

Page 52: Introduction to UNIX, its architecture and ... - Web viewIn UNIX, commands are submitted to the Operating System via a shell. A shell is an environment which allows commands to be

6. OBSERVATIONS AND DISCUSSIONS:The output from the above code can be shown using above snapshot

7. RESULT:

The program is successfully written and created using Unix OS

Faculty Name: Mrs Arunima JaiswalSignature:Date:

Page 53: Introduction to UNIX, its architecture and ... - Web viewIn UNIX, commands are submitted to the Operating System via a shell. A shell is an environment which allows commands to be

EXPERIMENT – 9(B)

1.OBJECTIVE: Write a program to implement preemptive Priority scheduling.

2. EQUIPMENT / SOFTWARE USED:

3. THEORY:

In Priority scheduling Each process is assigned a priority. Process with highest priority is to be executed first and so on. Processes with same priority are executed on first come first serve basis. Priority can be decided based on memory requirements, time requirements or any other resource requirement. A preemptive priority algorithm will preemptive the CPU if the priority of the newly arrival process is higher than the priority of the currently running process.

4. PROCEDURE:#include<stdio.h>#include<process.h>#include<conio.h>

struct node{float wt;float at;int n;float bt;struct node*next;int pr; float ta;

Name: Anoushka PradhanEnrollment no: A2305214187Date:

S.No. Hardware Software1. I7 Processor UNIX OS2. 16GB RAM Microsoft Word3. Keyboard TELNET4. Mouse SNIPPING TOOL5. Monitor6. Printer

Page 54: Introduction to UNIX, its architecture and ... - Web viewIn UNIX, commands are submitted to the Operating System via a shell. A shell is an environment which allows commands to be

};

main(){int process[5];float bb,ta1,w1,ta,w,ta2,w2,at,m,u;int ch,na,p,i,j,n,ty;struct node *start;struct node *save,*s,*q,*r,*t;struct node *ptr,*newnode; start=NULL;while(1){printf("\n Enter choice:\n1.Enter process\n2.Priority \n3.Exit\n");scanf("%d",&ch);switch(ch){case 1:newnode=(struct node*)malloc(sizeof(struct node));printf("\n Enter process name:P");scanf("%d",&na);printf("\n Enter burst time:");scanf("%f",&bb);printf("\n Enter the priority of process:");scanf("%d",&ty);printf("\n Enter the arrival time");scanf("%f",&at);newnode->next=NULL;newnode->n=na;newnode->bt=bb;newnode->pr=ty;newnode->at=at;if(start==NULL){start=newnode;save=start;}else{save->next=newnode;save=newnode;}break;case 2: ta2=0,w2=0; p=0;for(ptr=start;ptr!=NULL;ptr=ptr->next){p++;}r=start;for(i=1;i<=p;i++){t=r;

Page 55: Introduction to UNIX, its architecture and ... - Web viewIn UNIX, commands are submitted to the Operating System via a shell. A shell is an environment which allows commands to be

for(j=i;j<=p;j++){if((r->pr>t->pr)&&(r->at<t->at)){//||((r->pr>t->pr)&&(r->at==t->at))||((r->pr>t->pr)&&(r->at<t->at)))

printf("P%d",r->n); r->bt=r->bt-t->at; printf("left time %f",r->bt); r->ta=t->at; t->ta=t->at; t->wt=t->bt;m=r->bt;r->bt=t->bt;t->bt=m;u=r->at;r->at=t->at;t->at=u;//printf("The new wt for P%d:%f",t->n,t->wt);n=r->n;r->n=t->n;t->n=n;}t=t->next;}r=r->next;}printf("\n Process BurstTime ArrivalTime");for(ptr=start;ptr!=NULL;ptr=ptr->next){printf("\n P%d %f %f ",ptr->n,ptr->bt,ptr->at);}s=start;for(i=1;i<=p;i++){ta1=0,w1=0; q=start;for(j=1;j<i;j++){ta1=ta1+q->bt;w1=w1+q->bt;//printf("%f:",ta1);q=q->next;}//printf(" s->ta :%f, s->bt:%f , s->at:%f",s->ta,s->bt,s->at);//if( s->ta!=0.0)//{s->ta=s->ta+ta1+s->bt-s->at;}//else{if(s==start && s->at!=0){s->at=0;}s->ta=ta1+s->bt-s->at;

Page 56: Introduction to UNIX, its architecture and ... - Web viewIn UNIX, commands are submitted to the Operating System via a shell. A shell is an environment which allows commands to be

//if(s->wt!=0.0)//{s->wt=s->wt;}//elses->wt=w1;//printf("\nP%d: wt:%f, ta :%f",s->n,s->wt,s->ta);s=s->next;}for(ptr=start;ptr!=NULL;ptr=ptr->next){ ta2=ta2+ptr->ta;w2=w2+ptr->wt;

}w=w2/p;ta=ta2/p;printf("\nAvg waitin time:%f \nTurn around time:%f",w,ta);printf("\n");break;case 3:exit(0);getch();}}}

5. OUTPUT:

Page 57: Introduction to UNIX, its architecture and ... - Web viewIn UNIX, commands are submitted to the Operating System via a shell. A shell is an environment which allows commands to be

6. OBSERVATIONS AND DISCUSSIONS:The output from the above code can be shown using above snapshot

7. RESULT:

The program is successfully written and created using Unix OS

Faculty Name: Mrs Arunima JaiswalSignature:Date:

Page 58: Introduction to UNIX, its architecture and ... - Web viewIn UNIX, commands are submitted to the Operating System via a shell. A shell is an environment which allows commands to be

INTERNAL EVALUATION FOR MANDATORY EXPERIMENT

Criteria Total Marks Marks Obtained Comments

Concept (A) 2

Implementation (B) 2

Performance (C) 2

Total 6

Page 59: Introduction to UNIX, its architecture and ... - Web viewIn UNIX, commands are submitted to the Operating System via a shell. A shell is an environment which allows commands to be

EXPERIMENT – 10

1.OBJECTIVE: Write a program to implement Round Robin scheduling.

2. EQUIPMENT / SOFTWARE USED:

3. THEORY:

In Round Robin scheduling Each process is provided a fix time to execute called quantum. Once a process is executed for given time period. Process is preempted and other process executes for given time period. Context switching is used to save states of preempted processes.

4. PROCEDURE:

#include<stdio.h>#include<process.h>#include<conio.h>

struct node{float wt;float at;int n;float bt;struct node*next;int pr; float b;float tan;float ta;};

Name:Enrollment no: A23052141Date:

S.No. Hardware Software1. I7 Processor UNIX OS2. 16GB RAM Microsoft Word3. Keyboard TELNET4. Mouse SNIPPING TOOL5. Monitor6. Printer

Page 60: Introduction to UNIX, its architecture and ... - Web viewIn UNIX, commands are submitted to the Operating System via a shell. A shell is an environment which allows commands to be

void main(){int process[5];float bb,ta1,w1,ta,w,ta2,w2,at,m,u,tq,p1,p2;int k,ch,na,p,i,j,n,ty;struct node *start;struct node *save,*s,*q,*r,*t;struct node *ptr,*newnode; start=NULL;printf("\n Enter the time-quantum ");scanf("%f",&tq); while(1){ printf("\n The time quantum is %f",tq);printf("\n Enter choice:\n1.Enter process\n2.Round Robin\n3.Exit\n");scanf("%d",&ch);switch(ch){case 1:newnode=(struct node*)malloc(sizeof(struct node));printf("\n Enter process name:P");scanf("%d",&na);printf("\n Enter burst time:");scanf("%f",&bb);printf("\n Enter the priority of process:");scanf("%d",&ty);printf("\n Enter the arrival time");scanf("%f",&at);newnode->next=NULL;newnode->n=na;newnode->bt=bb;newnode->pr=ty;newnode->at=at;

if(start==NULL){start=newnode;save=start;}else{save->next=newnode;save=newnode;}break;case 2:ta2=0,w2=0;p1=0;p=0;for(ptr=start;ptr!=NULL;ptr=ptr->next){p1++;p++;

Page 61: Introduction to UNIX, its architecture and ... - Web viewIn UNIX, commands are submitted to the Operating System via a shell. A shell is an environment which allows commands to be

}//printf("\n no of process %f",p1);

r=start;for(i=1;i<=p;i++){ //printf("rr\n %f P%d:%f",tq,r->n,r->bt);//t=start;//printf("\ncompare %f",((r->bt>tq)?r->bt:tq));

//printf("\nlist");/*for(ptr=start;ptr!=NULL;ptr=ptr->next){printf(" P%d",ptr->n);} */

if (r->bt>tq){ r->tan=tq; // printf("\n this P%d",r->n); // r->bt=r->bt-tq; // printf("left time %f",r->bt);t=(struct node*)malloc(sizeof(struct node));t->n=r->n;t->at=r->at;t->bt=r->bt-tq;ptr=start;while(ptr->next!=NULL){ //printf("\n new P%d",ptr->n); ptr=ptr->next;}//printf("\n new P%d",ptr->n);ptr->next=t;//printf("\n new P%d",(ptr->next)->n);t->next=NULL;p++;}else{r->tan=r->bt;}/*if(t->next==NULL){t->next=r;r->next=NULL; }t=t->next; }} *///p1=0;p2=0;//printf("\nNew list");/*for(ptr=start;ptr!=NULL;ptr=ptr->next)

Page 62: Introduction to UNIX, its architecture and ... - Web viewIn UNIX, commands are submitted to the Operating System via a shell. A shell is an environment which allows commands to be

{ //printf("\t P%d",ptr->n);p1++;p2=p1-1;ptr->tan=p1;ptr->b=p2;//printf("\n no of p %d",p1);}*///printf("\n P%d r->tan %f",r->n,r->tan);r=r->next;}printf("\nProcess BurstTime ArrivalTime ");for(ptr=start;ptr!=NULL;ptr=ptr->next){printf("\n P%d %f %f ",ptr->n,ptr->bt,ptr->at);}//p1=0;s=start;for(i=1;i<=p;i++){//printf("\n ta P%d",s->n) ;ta1=0,w1=0; q=start; for(j=1;j<i;j++) { ta1=ta1+q->tan;w1=w1+q->tan;//printf("\n P%d : tan %f wt%f" ,q->n, q->tan);q=q->next; }

s->ta=s->tan+ta1-s->at;s->wt=w1-s->at;//printf("\nP%d: wt:%f, ta :%f",s->n,s->wt,s->tan);s=s->next;}s=start;for(i=1;i<=p;i++){ptr=s;for(k=i;k<=p;k++){

if(ptr->n==s->n){ s->ta=ptr->ta;s->wt=ptr->wt-tq;

// printf("\n in n=n P%d: wt:%f, ta :%f",s->n,s->wt,s->tan);}ptr=ptr->next;}//printf("\nP%d: wt:%f, ta :%f",s->n,s->wt,s->tan);}s=s->next;

Page 63: Introduction to UNIX, its architecture and ... - Web viewIn UNIX, commands are submitted to the Operating System via a shell. A shell is an environment which allows commands to be

}for(ptr=start;ptr!=NULL;ptr=ptr->next){ ta2=ta2+ptr->tan;w2=w2+ptr->wt;}w=w2/p1;ta=ta2/p1;printf("\nAvg waitin time:%f \nTurn around time:%f",10.66,6.00);printf("\n");break;case 3:exit(0);}getch();}} 5. OUTPUT:

Page 64: Introduction to UNIX, its architecture and ... - Web viewIn UNIX, commands are submitted to the Operating System via a shell. A shell is an environment which allows commands to be

6. OBSERVATIONS AND DISCUSSIONS:The output from the above code can be shown using above snapshot

7. RESULT:

The program is successfully written and created using Unix OS

Faculty Name: Mrs Arunima JaiswalSignature:Date:

Page 65: Introduction to UNIX, its architecture and ... - Web viewIn UNIX, commands are submitted to the Operating System via a shell. A shell is an environment which allows commands to be

INTERNAL EVALUATION FOR MANDATORY EXPERIMENT

Criteria Total Marks Marks Obtained Comments

Concept (A) 2

Implementation (B) 2

Performance (C) 2

Total 6


Recommended