You are on page 1of 40

Hidayat 2K21CSUN01071 CSE 4B

OS LAB FILE

Submitted By:- Hidayat Ulla Bukhari


2K21CSUN01071
B.Tech CSE 4B
Submitted To – Dr. Jyoti Pruthi

INDEX:

pg. 1
Hidayat 2K21CSUN01071 CSE 4B

S.NO TITLE SIGNATURE


1 Lab 0
2 Lab 1
3 Lab 2
4 Lab 3
5 Lab 4
6 Lab 5-8
7 Lab 9
8 Lab 10
9 Lab 11

pg. 2
Hidayat 2K21CSUN01071 CSE 4B

LAB -0

DEPARTMENT OF COMPUTER SCIENCE & TECHNOLOGY

Lab-0
Laboratory Objective: To revisit and implement C Programming Concepts
Learning Outcome: To gain familiarity with the concepts of C.

Course Outcome: CO1


Blooms Taxonomy: BT1, BT2, BT3, BT4
Write programs using the C/C++ Language
Basics
1. To swap two numbers without using a temporary variable.
2. To calculate the bill amount for an item given the quantity sold, rate, discount and tax.

Based on Decision Control


3. Program to enter any character. If the entered character is in lower case then convert it into upper
case and if it is lower case then convert it into upper case.

4. To enter a character and determine whether it is vowel or not.

Based on Switch Case:


5. Program to display a menu that offers five options: Read three numbers, calculate total, average,
display the smallest and largest value.

Based on Iterative Statements


6. To classify a number as prime or composite.

Based on Functions
7. To find the Fibonacci using recursive function.

Based on Arrays
8. To insert a number at a given location in an array.

pg. 3
Hidayat 2K21CSUN01071 CSE 4B

9. In a class there are 10 students. Each student is supposed to appear in three tests. Write a program
using 2D array to print
(a) The marks obtained by each student in different subjects.

(b) Sort the average obtained by each student.

10. Accept any two strings from the user. Display whether both the strings are equal or not. (do not
use standard functions).

Based on Structures
11. Write a program to accept a list of 10 integers in an array, pass the starting address of array in
sum function, calculate the sum of the array elements in the function and return the sum
calculated in the main function.

Based on Command Line Arguments


12. Program to add two numbers using Command Line Arguments.

1. To swap two numbers without using a temporary variable.

pg. 4
Hidayat 2K21CSUN01071 CSE 4B

2. To calculate the bill amount for an item given the quantity sold, rate, discount and tax.

pg. 5
Hidayat 2K21CSUN01071 CSE 4B

Based on Decision Control

3. Program to enter any character. If the entered character is in lower case then convert it into upper case and
if it is lower case then convert it into upper case.

4. To enter a character and determine whether it is vowel or not.

pg. 6
Hidayat 2K21CSUN01071 CSE 4B

Based on Iterative Statements

5. To classify a number as prime or composite.

Based on Functions

6. To find the Fibonacci using recursive function.

pg. 7
Hidayat 2K21CSUN01071 CSE 4B

Based on Arrays

7. To insert a number at a given location in an array.

8. In a class there are 10 students. Each student is supposed to appear in three tests. Write a program using 2D
array to print
(a) The marks obtained by each student in different subjects.

(b) Sort the average obtained by each student.

pg. 8
Hidayat 2K21CSUN01071 CSE 4B

9. Accept any two strings from the user. Display whether both the strings are equal or not. (do not use
standard functions).

pg. 9
Hidayat 2K21CSUN01071 CSE 4B

Based on Structures

10. Write a program to accept a list of 10 integers in an array, pass the starting address of array in sum function,
calculate the sum of the array elements in the function and return the sum calculated in the main function.

Based on Command Line Arguments

11. Program to add two numbers using Command Line Arguments.

pg. 10
Hidayat 2K21CSUN01071 CSE 4B

DEPARTMENT OF COMPUTER SCIENCE & TECHNOLOGY

Lab-1

Laboratory Objective: To implement Basic system calls of UNIX Operating System


Learning Outcome: Familiarity with the use of basic calls of UNIX

Course Outcome: CO2


Blooms Taxonomy: BT1, BT2, BT3
Write programs using the following system calls of UNIX operating system
12. fork()

13. exec()

14. getpid()

15. exit()

16. wait()

pg. 11
Hidayat 2K21CSUN01071 CSE 4B

1. fork()

2. exec()

pg. 12
Hidayat 2K21CSUN01071 CSE 4B

3. getpid()

4. exit()

pg. 13
Hidayat 2K21CSUN01071 CSE 4B

5. wait()

pg. 14
Hidayat 2K21CSUN01071 CSE 4B

LAB-2
1. closedir()
• The closedir() function closes the directory stream associated with dirp. A
successful call to closedir() also closes the underlying file descriptor associated
with dirp. The directory stream descriptor dirp is not available after this call.
• The closedir() function returns 0 on success. On error, -1 is returned, and
errno is set to indicate the error.

2. opendir()
• The opendir() function opens a directory stream corresponding to the directory
name, and returns a pointer to the directory stream. The stream is positioned
at the first entry in the directory.
• The opendir() function return a pointer to the directory stream. On error,
NULL is returned, and errno is set to indicate the error.

pg. 15
Hidayat 2K21CSUN01071 CSE 4B

pg. 16
Hidayat 2K21CSUN01071 CSE 4B

3. readdir()
• The readdir() function returns a pointer to a dirent structure representing the
next directory entry in the directory stream pointed to by dirp. It returns NULL
on reaching the end of the directory stream or if an error occurred.
• On success, readdir() returns a pointer to a dirent structure.

pg. 17
Hidayat 2K21CSUN01071 CSE 4B

Lab-3
Open():
The open() system call opens the file specified by pathname. If the specified
file does not exist, it may optionally be created by open()
The return value of open() is a file descriptor, a small non negative integer
that is an index to an entry in the process table of open file descriptors.

pg. 18
Hidayat 2K21CSUN01071 CSE 4B

Read():
read() function shall attempt to read n bytes from the file associated wi8th the
open file descriptor, fildes into the buffer pointed to by buf
it reads data previously written into the file.

Write():
write() function shall attempt to write nbytes from the buffer pointed to by
buf to the file associated with the open file descriptor

pg. 19
Hidayat 2K21CSUN01071 CSE 4B

Stat()
The stat() function shall obtain info about the named file and write it to the
area pointed to by buf argument
Upon successful completion,0 shall be returned.otherwise -1 shall be returned

Close()
The close() fuction shall deallocate the file descriptor indicated by fildes. To
deallocate means to make the file descriptor available for return by
subsequent calls

Lab-4
Laboratory Objective: To implement I/O system calls of UNIX

pg. 20
Hidayat 2K21CSUN01071 CSE 4B

Write programs using the I/O System calls of UNIX operating system

1. stat()

2. close()

pg. 21
Hidayat 2K21CSUN01071 CSE 4B

pg. 22
Hidayat 2K21CSUN01071 CSE 4B

Lab-5 - Lab-8
Laboratory Objective: To implement scheduling algorithms in C.
1. Implement the following scheduling algorithms in C on the given scenario:

Process Arrival Time Burst Time


P1 0 8
P2 1 4
P3 2 9
p4 3 5
a) FCFS

pg. 23
Hidayat 2K21CSUN01071 CSE 4B

b) SJF

pg. 24
Hidayat 2K21CSUN01071 CSE 4B

pg. 25
Hidayat 2K21CSUN01071 CSE 4B

c) SRTF

pg. 26
Hidayat 2K21CSUN01071 CSE 4B

pg. 27
Hidayat 2K21CSUN01071 CSE 4B

d) RR

pg. 28
Hidayat 2K21CSUN01071 CSE 4B

LAB-9

pg. 29
Hidayat 2K21CSUN01071 CSE 4B

Producer-Consumer problem
Code-:

pg. 30
Hidayat 2K21CSUN01071 CSE 4B

Output-:

pg. 31
Hidayat 2K21CSUN01071 CSE 4B

Lab-10
FIRST FIT:

BEST FIT:

WORST FIT:

pg. 32
Hidayat 2K21CSUN01071 CSE 4B

LAB-11
PAGE REPLACEMENT

pg. 33
Hidayat 2K21CSUN01071 CSE 4B

A page replacement algorithm is required in an operating system that


employs paging to manage memory in order to determine which page has
to be replaced when a new page is received.

1. First In First Out (FIFO)

pg. 34
Hidayat 2K21CSUN01071 CSE 4B

pg. 35
Hidayat 2K21CSUN01071 CSE 4B

2. Optimal Page replacement:

pg. 36
Hidayat 2K21CSUN01071 CSE 4B

pg. 37
Hidayat 2K21CSUN01071 CSE 4B

3. Least Recently Used:

pg. 38
Hidayat 2K21CSUN01071 CSE 4B

pg. 39
Hidayat 2K21CSUN01071 CSE 4B

pg. 40

You might also like