This repository contains Programs for the Operating System Lab Course. Here I provide C Programs and some shell scripts and also the problem statement for some. If you find any error in code or the code is giving some Wrong Output you can raise a issue here. If you like it, consider giving a Star !!
Problem:
The Dining Philosopher Problem states that K philosophers are seated around a circular table with one chopstick between each pair of philosophers. There is one chopstick between each philosopher. A philosopher may eat if he can pick up the two chopsticks adjacent to him. One chopstick may be picked up by any one of its adjacent followers but not both.
Output:
Problem:
We have a buffer of fixed size. A producer can produce an item and can place in the buffer. A consumer can pick items and can consume them. We need to ensure that when a producer is placing an item in the buffer, then at the same time consumer should not consume any item.
Output:
Write a C program using Pipes for the following a) Create 2 Process (Child and Parent) b) Child Process must request the Parent process to compute the factorial of a number. c) Child Process must read a number from the user.
Output:
Write a C Program using Named Pipes (FIFOS) a) Create 2 Process(Sender and Receiver)(Un related - i.e, belonging to 2 separate applications) b) Sender process has to send u’r details (RegNo, Name, Course, School) to the Receiver process.
Output:
Use message queues in a C programme to construct a basic conversation programme between two unrelated, independent processes. Additionally, the programme must terminate until one of the processes posts the message "stop."
Output:
Write a C Program using Shared Memory b/w 2 processes for exchanging the below message: “Inter-Process Communication (IPC) plays a vital role in the world of operating systems, enabling different processes to communicate and cooperate with each other. IPC is crucial for multi-tasking, enabling processes to share data, synchronize their activities, and collaborate effectively”
Output:
First-fit allocation is a memory allocation algorithm that goes through a list of free blocks of memory and assigns the task to the first block large enough to accommodate the request.
In Best-Fit, the operating system searches through the list of free blocks of memory to find the block that is closest in size to the memory request from the process
It involves finding and allocating the largest available block of memory to the process in question.
FIFO algorithm replaces the oldest (First) page which has been present for the longest time in the main memory.
This algorithm is based on the strategy that whenever a page fault occurs, the least recently used page will be replaced with a new page.
This algorithm replace the page that will be referenced furthest in the future or not at all.
The LFU algorithm counts how often an item is needed; those used less often are discarded first. This is similar to LRU, except that how many times a block was accessed is stored instead of how recently.
Write a function foo(int fd, char* buf, int b_size, int n, int skip) that reads to buf from file with file descriptor fd, n blocks of size b_size each. The last argument specifies how many bytes to skip after reading each block. Return -1 if the operation is unsuccessful. Else return total number of bytes read.
Output:
Write a program to read all txt files (that is files that ends with .txt) in the current directory and merge them all to one txt file and returns a file descriptor for the new file.
Output:
Write a program that takes a string as an argument and return all the files that begins with that name in the current directory and its sub directories. For example, > ./a.out foo will return all file names that begins with foo.
Output:
Write a program that will categorize all files in the current folder based on their file type. That is all .txt file in one folder called txt, all .bmp files in another folder called bmp etc. The argument to the program is a folder name.
Output:
Given a directory, write a program that will find all files with the same name in the directory and its sub directories. Show their name, which folder they are in and what day they were created. Expand the program to remove all duplicate copies based on user input. That is, ask user if each one of the file is to be kept or deleted. Based on user input, perform the appropriate action.
Output:
Create two functions: one to generate the list of Odd_Numbers b/w 'n' and 'm', and another to generate Even_Numbers b/w 'n' and 'm'. In order to invoke the aforementioned techniques, construct a C programme that creates two processes, one of which calls the Even_Number list and the other the Odd_Number list
Output:
Develop two distinct programmes. One should be used to generate Fibonacci Series upto 'n' terms (let's say Fibo.c), and the other should produce a list of PrimeNumbers b/w 'n' and 'm' (let's say Prime.c). Now develop a C programme that uses fork() to split into two processes, one that runs Fibo.c and the other that runs Prime.c.
Output: