Os Record Final
Os Record Final
Os Record Final
Aim:
Step1:
Connect a blank USB flash drive or insert a blank writable DVD.
Step2:
Make sure you have a product key.
Step3:
Go to https://www.microsoft.com/en-us/software-download/windows10%20.
Step4:
Click Download tool now.
Step5:
Double-click the downloaded file.
Step6:
Click Accept to accept the license.
Step7:
Select "Create installation media" and click OK.
Step8:
Select your preferences and click Next.
Step9:
Choose an installation type and click Next.
Step10:
Create your installation media.
Result:
Date:
COMMANDS
Result:
Thus to illustrate Basics of UNIX commands is executed successfully.
2. (B): SHELL PROGRAMMING
Algorithm:
1)Define the shebang.
2)Define variables.
3) Write the main logic of your script.
4) Use built-in shell commands or call external programs to perform the actions required by your
script.
Program:
#!/bin/bash
# This is a comment
# Use a loop
for (( i=1; i<=5; i++ )); do
echo "Count: $i"
done
Result:
Thus to implement Shell Programming using bash is successfully executed and verified.
Ex. No: 3 A PROCESS MANAGEMENT USING SYSTEM CALLS: FORK
Date :
Aim:
To implement fork system call using c.
Algorithm:
1)Include the necessary header files.
2)Call the fork() function.
3) After calling fork(), you need to check the return value to determine whether you are in the parent
or child process.
4) Based on the return value of fork(), you can now branch your code accordingly for the parent
and child processes.
5) Execute the code.
Program:
#include <stdio.h>
#include <unistd.h>
int main() {
pid_t pid;
if (pid < 0) {
// Error occurred while forking
fprintf(stderr, "Fork failed\n");
return 1;
} else if (pid == 0) {
// Child process
printf("Child process\n");
// Perform child-specific tasks
} else {
// Parent process
printf("Parent process\n");
// Perform parent-specific tasks
}
return 0;
}
Output:
Parent process
Child process
Result:
Thus to implement fork system call using c is successfully executed and verified.
Ex. No: 3 B PROCESS MANAGEMENT USING SYSTEM CALLS: EXIT
Date :
Aim:
Algorithm:
Program:
#include <stdlib.h>
#include <stdio.h>
void cleanup() {
// Code to clean up resources before exiting
printf("Cleaning up resources...\n");
// Cleanup code goes here
}
int main() {
// Code execution before exit call
Cleaning up resources…
Result:
Thus to implement exit system call using c is successfully executed and verified.
Ex. No: 3 C PROCESS MANAGEMENT USING SYSTEM CALLS: GETPID
Date :
Aim:
Algorithm:
Program:
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
int main() {
pid_t pid;
return 0;
}
Output:
Result:
Thus to implement Getpid system call using c is successfully executed and verified.
Ex. No: 3 D PROCESS MANAGEMENT USING SYSTEM CALLS: WAIT
Date :
Aim:
Algorithm:
Program:
#include <stdio.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
int main() {
pid_t pid;
int status;
(pid < 0) {
// Error occurred while forking
fprintf(stderr, "Fork failed\n");
return 1;
} else if (pid == 0) {
// Child process
printf("Child process running...\n");
sleep(5); // Simulating some work in the child process
printf("Child process done.\n");
} else {
// Parent process
printf("Parent process waiting for child...\n");
wait(&status); // Wait for child process to finish
printf("Parent process resumed.\n");
}
return 0;
}
Output:
Result:
Thus to implement wait system call using c is successfully executed and verified.
Ex. No: 3 E PROCESS MANAGEMENT USING SYSTEM CALLS: CLOSE
Date :
Aim:
Algorithm:
Program:
#include <unistd.h>
#include <stdio.h>
int main() {
int file_descriptor = 123; // Replace with your file descriptor
if (close(file_descriptor) == -1) {
perror("Error closing file");
return 1;
}
Result:
Thus to implement close system call using c is successfully executed and verified.
Ex. No: 4 A IMPLEMENT THE VARIOUS CPU SCHEDULING ALGORITHMS
Aim:
Algorithm:
Program:
#include <stdio.h>
int main()
{
int i, j, n, bt[20], wt[20], tat[20], ct[20], temp, totalwt = 0, totaltat = 0;float
avgwt, avgtat;
tat[i] = ct[i];
wt[i] = tat[i] - bt[i];
totalwt += wt[i];
totaltat += tat[i];
}
return 0;
}
Output:
Result:
Thus to implement FCFS scheduling algorithm using c is successfully executed and verified.
Ex. No: 4 B SHORTEST JOB FIRST (SJF) SCHEDULING ALGORITHM
Date :
Aim:
Algorithm:
Program:
#include <stdio.h>
struct Process {
int pid; // Process ID int
arrival; // Arrival time
int burst; // Burst time int
waiting; // Waiting time
int turnaround; // Turnaround time
};
completed = 0, current_time = 0;
while (completed != n) {
int shortest = -1; // Index of the process with the shortest remaining time
int main() {
int n;
printf("Enter the number of processes: ");scanf("%d",
&n);
struct Process processes[n];
printf("\nEnter the arrival time and burst time for each process:\n");for (int i
= 0; i < n; i++) {
processes[i].pid = i + 1;
printf("Process %d:\n", i + 1);
printf("Arrival Time: ");
scanf("%d", &processes[i].arrival);
printf("Burst Time: ");
scanf("%d", &processes[i].burst);
}
sjf_scheduling(processes, n);
return 0;
}
Output:
Result:
Thus to implement Shortest Job First Scheduling Algorithm using c is successfully executed and verified.
Ex. No: 4 C PRIORITY SCHEDULING ALGORITHMS
Date:
Aim:
Algorithm:
Program:
#include<stdio.h>
void main() {
int n, i, j, temp;
int arrival_time[20], burst_time[20], priority[20], waiting_time[20], turnaround_time[20]; float
avg_waiting_time = 0, avg_turnaround_time = 0;
printf("\nEnter the arrival time, burst time and priority of each process:\n");for(i =
0; i < n; i++) {
printf("\nProcess[%d]\n", i + 1);
printf("Arrival time: ");
scanf("%d", &arrival_time[i]);
printf("Burst time: "); scanf("%d",
&burst_time[i]);
printf("Priority: ");
scanf("%d", &priority[i]);
}
temp = arrival_time[i];
arrival_time[i] = arrival_time[j];
arrival_time[j] = temp;
}
}
}
avg_waiting_time += waiting_time[i];
avg_turnaround_time += turnaround_time[i];
}
avg_waiting_time /= n;
avg_turnaround_time /= n;
printf("\nAverage waiting time: %f", avg_waiting_time);
printf("\nAverage turnaround time: %f", avg_turnaround_time);
}
Output:
Result:
Thus to implement Priority Scheduling Algorithms using c is successfully executed and verified.
Ex. No: 4 D ROUND ROBIN SCHEDULING ALGORITHMS
Date :
Aim:
Algorithm:
Program:
#include <stdio.h>
#define MAX_PROCESSES 10
#define TIME_QUANTUM 4
struct process {
int pid; // Process IDint
burst; // Burst time
int remaining; // Remaining time
};
int main() {
struct process p[MAX_PROCESSES];int n,
i, t, completed = 0;
int wait_time = 0, turnaround_time = 0; printf("Enter
scanf("%d", &n);
return 0;
}
Output:
Result:
Thus to implement Round Robin Scheduling Algorithms using c is successfully executed and
verified.
Ex. No : 5 ILLUSTRATE THE INTER PROCESS COMMUNICATION STRATEGY
Date :
Aim:
Algorithm:
Program:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
int main()
{
int fd[2]; // file descriptors for pipe
pid_t pid;
Result:
Thus to illustrate Inter process communication strategy using c is successfully executed and verified.
Ex. No : 6 IMPLEMENT MUTUAL EXCLUSION BY SEMAPHORE
Date :
Aim:
Algorithm:
Program:
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <semaphore.h>
#define NUM_THREADS 2
int shared_data = 0;
sem_t mutex;
int main() {
pthread_t threads[NUM_THREADS];
int thread_ids[NUM_THREADS] = {0, 1};int
i;
// create threads
for (i = 0; i < NUM_THREADS; i++) {
pthread_create(&threads[i], NULL, thread_func, &thread_ids[i]);
}
// wait for threads to finish
for (i = 0; i < NUM_THREADS; i++) {
pthread_join(threads[i], NULL);
}
return 0;
}
Output:
Result:
Thus to implement mutual exclusion by semaphore using c is successfully executed and verified.
Ex. No : 7 AVOID DEADLOCK USING BANKER’S ALGORITHM
Date :
Aim:
Algorithm:
Program:
#include <stdio.h>
#define MAX_RESOURCES 5
if (safe) {
for (i = 0; i < MAX_RESOURCES; i++) {
available_resources -= request[i];
allocated_resources_array[i] += request[i];
need_resources_array[i] -= request[i];
}
allocated_resources += 1;
}
return safe;
}
void release_resources(int release[])
{
int i;
void print_state()
{
printf("Available resources: %d\n", available_resources);
printf("Allocated resources: %d\n", allocated_resources);
printf("Max requests: ");
for (int i = 0; i < MAX_RESOURCES; i++)
{
printf("%d ", max_requests[i]);
}
printf("\n");
printf("Allocated resources array: ");
for (int i = 0; i < MAX_RESOURCES; i++) {
printf("%d ", allocated_resources_array[i]);
}
printf("\n");
printf("Need resources array: ");
for (int i = 0; i < MAX_RESOURCES; i++) {printf("%d
", need_resources_array[i]);
}
printf("\n");
}
int main()
{
int request[MAX_RESOURCES] = {0, 0, 0, 0, 0};
int release[MAX_RESOURCES] = {0, 0, 0, 0, 0};
if (request_resources(request)) {
printf("Request granted.\n");
} else {
printf("Request denied.\n");
}
print_state();
// Release some resources
release[0] = 1;
release[1] = 2;
release[2] = 3;
release[3] = 4;
release[4] = 5;
release_resources(release);
print_state();
return 0;
}
Output:
Result:
Thus to avoid Deadlock using Banker's Algorithm in c is successfully executed and verified.
Ex. No : 8 IMPLEMENT DEADLOCK DETECTION ALGORITHM
Date :
Aim:
Algorithm:
Program:
#include <stdio.h>
int main()
{
int n, m, i, j, k;
printf("Enter the number of processes: ");scanf("%d",
&n);
printf("Enter the number of resources: ");scanf("%d",
&m);
while(count < n)
{
int found = 0;
for(i=0; i<n; i++)
{
if(finish[i] == 0)
{
int flag = 1;
for(j=0; j<m; j++)
{
if(need[i][j] > work[j])
{
flag = 0;
break;
}
}
if(flag)
{
for(k=0; k<m; k++)
{
work[k] += allocation[i][k];
}
safe[count] = i;
count++;
finish[i] = 1;
found = 1;
}
}
}
if(!found)
{
printf("Deadlock detected!\n");
return 0;
}
}
printf("System is in safe state.\n");
printf("Safe sequence is: "); for(i=0;
i<n; i++)
{
printf("%d ", safe[i]);
}
printf("\n");
return 0;
}
Output:
Result:
Thus to implement deadlock detection algorithm using c is successfully executed and verified.
Ex. No : 9 IMPLEMENTATION OF THREADING
Date :
Aim:
Algorithm:
Program:
#include <stdio.h>
#include <pthread.h>
void *thread_function(void *arg);
return 0;
}
Result:
Date :
Aim:
Algorithm:
Program:
#include <stdio.h>
int main() {
int page_table[NUM_PAGES] = {-1}; // initialize all entries to -1
int physical_mem[NUM_PAGES * PAGE_SIZE] = {0}; // initialize physical memory to 0int
virtual_mem_size, logical_address, page_num, offset, physical_address, value;
if (logical_address == -1) {
break;
}
return 0;
}
Output:
Result:
Thus to implement the paging technique using c is successfully executed and verified.
Ex. No : 11 A FIRST FIT MEMORY ALLOCATION ALGORITHM
Date :
Aim:
Algorithm:
Program:
#include <stdio.h>
return;
}
}
printf("Memory allocation failed.\n");
}
displayBlocks(blocks, numBlocks);int
processSize;
printf("\nEnter the size of the process to be allocated: ");
scanf("%d", &processSize);
numBlocks);
return 0;
}
Output:
Result:
Thus to implement First Fit Memory Allocation Algorithm using c is successfully executed and
verified.
Ex. No : 11 B WORST FIT MEMORY ALLOCATION ALGORITHM
Date :
Aim:
Algorithm:
Program:
#include <stdio.h>
if (maxBlockIndex != -1) {
// Allocate memory blocks[maxBlockIndex].allocated
= 1; blocks[maxBlockIndex].size -= processSize;
blocks[maxBlockIndex].end -= processSize;
printf("Memory allocated successfully.\n");
printf("Allocated block: %d\n", maxBlockIndex);
printf("Allocated memory size: %d\n", processSize);
printf("Remaining block size: %d\n", blocks[maxBlockIndex].size);
} else
{
printf("Memory allocation failed.\n");
}
}
int main() {
int numBlocks = 5;
MemoryBlock blocks[MAX_SIZE] = {
{0, 99, 100, 0},
{100, 199, 100, 0},
{200, 299, 100, 0},
{300, 399, 100, 0},
{400, 499, 100, 0}
};
displayBlocks(blocks, numBlocks);int
processSize;
printf("\nEnter the size of the process to be allocated: ");
scanf("%d", &processSize);
numBlocks);
return 0;
}
Output:
Result:
Thus to implement Worst Fit Memory Allocation Algorithm using c is successfully executed and
verified.
Ex. No : 11 C BEST FIT MEMORY ALLOCATION ALGORITHM
Date :
Aim:
To implement Best Fit Memory Allocation Algorithm using c is successfully executed and verified.
Algorithm:
Program:
#include <stdio.h>
if (minBlockIndex != -1) {
// Allocate memory blocks[minBlockIndex].allocated
= 1; blocks[minBlockIndex].size -= processSize;
blocks[minBlockIndex].end -= processSize;
printf("Memory allocated successfully.\n"); printf("Allocated
block: %d\n", minBlockIndex); printf("Allocated memory size:
%d\n", processSize);
printf("Remaining block size: %d\n", blocks[minBlockIndex].size);
} else {
printf("Memory allocation failed.\n");
}
}
int main() {
int numBlocks = 5;
MemoryBlock blocks[MAX_SIZE] = {
{0, 99, 100, 0},
{100, 199, 100, 0},
{200, 299, 100, 0},
{300, 399, 100, 0},
{400, 499, 100, 0}
};
displayBlocks(blocks, numBlocks);int
processSize;
printf("\nEnter the size of the process to be allocated: ");
scanf("%d", &processSize);
numBlocks);
return 0;
}
Output:
Result:
Thus to implement Best Fit Memory Allocation Algorithm using c is successfully executed and
verified.
Ex. No : 12 A FIRST-IN-FIRST-OUT (FIFO) PAGE REPLACEMENT ALGORITHM
Date :
Aim:
To implement FIFO Page Replacement Algorithm using c.
Algorithm:
Program:
MAX_FRAMES 3
if (!pageExists)
{
frames[frameIndex] = currentPage;
frameIndex = (frameIndex + 1) % MAX_FRAMES;
pageFaults++;
}
int main()
{
int pages[] = {1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5};
int n = sizeof(pages) / sizeof(pages[0]);
return 0;
}
Output:
Result:
Thus to implement FIFO Page Replacement Algorithm using c is successfullyexecuted and verified.
Ex. No : 12 B LRU PAGE REPLACEMENT ALGORITHM
Date :
Aim:
Algorithm:
Program:
MAX_FRAMES 3
if (!pageExists)
{
int leastRecentIndex = 0;
for (j = 1; j < MAX_FRAMES; j++)
{
if (frameIndex[j] < frameIndex[leastRecentIndex])
leastRecentIndex = j;
}
frames[leastRecentIndex] = currentPage;
frameIndex[leastRecentIndex] = i;
pageFaults++;
}
return 0;
}
Output:
Result:
Thus to implement LRU Page Replacement Algorithm using c is successfullyexecuted and verified.
Ex. No : 13 A SEQUENTIAL FILE ORGANIZATION TECHNIQUE
Date :
Aim:
To implement Sequential File Organization Technique using c.
Algorithm:
Program:
#include <stdio.h>
#include <stdlib.h>
struct Student {
int rollNo;
char name[50];
float marks;
};
int main() {
FILE* fp;
struct Student s;
}
s.rollNo = 1; strcpy(s.name,
"John"); s.marks = 85.5;
writeStudentRecord(fp, s);
s.rollNo = 2; strcpy(s.name,
"Alice"); s.marks = 90.0;
writeStudentRecord(fp, s);
fclose(fp);
readStudentRecord(fp);
fclose(fp);
return 0;
}
Output:
Roll No: 1
Name: John
Marks: 85.50
Roll No: 2
Name: Alice
Marks: 90.00
Result:
Thus to implement Sequential File Organization Technique using c is successfully executed and verified.
Ex. No : 13 B INDEXED FILE ORGANIZATION TECHNIQUE
Date :
Aim:
To implement Indexed File Organization Technique using c.
Algorithm:
Program:
#include <stdio.h>
#include <stdlib.h>
struct Student {
int rollNo;
char name[50];
float marks;
};
struct Index {
int rollNo;
long int offset;
};
void writeStudentRecord(FILE* fp, struct Student s, struct Index* index, int* indexCount) {
fwrite(&s, sizeof(struct Student), 1, fp);
index[*indexCount].rollNo = s.rollNo; index[*indexCount].offset
= ftell(fp) - sizeof(struct Student);(*indexCount)++;
}
void readStudentRecord(FILE* fp, struct Index* index, int indexCount, int rollNo) { int i;
for (i = 0; i < indexCount; i++) {
if (index[i].rollNo == rollNo) {
fseek(fp, index[i].offset, SEEK_SET);
struct Student s;
fread(&s, sizeof(struct Student), 1, fp);
printf("Roll No: %d\nName: %s\nMarks: %.2f\n\n", s.rollNo, s.name, s.marks);return;
}
}
printf("Record not found.\n");
}
int main() {
FILE* fp;
struct Student s;
struct Index index[100];
int indexCount = 0;
s.rollNo = 1;
strcpy(s.name, "John");
s.marks = 85.5;
writeStudentRecord(fp, s, index, &indexCount);
s.rollNo = 2;
strcpy(s.name, "Alice");
s.marks = 90.0;
writeStudentRecord(fp, s, index, &indexCount);
fclose(fp);
int rollNo;
fclose(fp);
return 0;
}
Output:
Result:
Date :
Aim:
To implement Hashing File Organization Technique using c.
Algorithm:
Program:
#include <stdio.h>
#include <stdlib.h>
#define SIZE 10
struct Student {
int rollNo;
char name[50];
float marks;
};
s.rollNo = -1;
for (int i = 0; i < SIZE; i++) {
writeStudentRecord(fp, s);
}
fclose(fp);
s.rollNo = 2;
strcpy(s.name, "Alice");
s.marks = 90.0;
index = hashFunction(s.rollNo);
writeStudentRecord(fp, s);
fclose(fp);
return 0;
}
Output:
Result:
Thus to implement Hashing File Organization Technique using c is successfully executed and
verified.
Ex. No : 14 A SEQUENTIAL FILE ALLOCATION STRATEGY
Date :
Aim:
To implement Sequential File Allocation Strategy using c.
Algorithm:
Program:
#include <stdio.h>
#include <stdlib.h>
typedef struct {
char fileName[20];
int startBlock;
int fileSize;
} File;
File files[MAX_FILE_SIZE];
numFiles; i++) {
return 0;
}
Output:
Result:
Thus to implement Sequential File Allocation Strategy using c is successfully executed and
verified.
Ex. No : 14 B INDEXED FILE ALLOCATION STRATEGY
Date :
Aim:
To implement Indexed File Allocation Strategy using c.
Algorithm:
Program:
#include <stdio.h>
#include <stdlib.h>
typedef struct {
char fileName[20];
int fileSize;
int indexBlock[MAX_INDEX_SIZE];
} File;
int main() {
int numFiles;
printf("Enter the number of files: ");
scanf("%d", &numFiles);
File files[MAX_FILE_SIZE];
for (int i = 0; i < numFiles; i++) {
printf("Enter the file name: ");
scanf("%s", files[i].fileName);
printf("Enter the file size: ");
scanf("%d", &files[i].fileSize);
}
allocateIndexed(files, numFiles);
return 0;
}
Output:
Result:
Thus to implement Indexed File Allocation Strategy using c is successfully executed and verified.
Ex. No : 14 C LINKED FILE ALLOCATION STRATEGY
Date :
Aim:
To implement Linked File Allocation Strategy using c.
Algorithm:
Program:
#include <stdio.h>
#include <stdlib.h>
typedef struct {
char fileName[20];
int fileSize;
Block* firstBlock;
} File;
int main() {
int numFiles;
printf("Enter the number of files: ");
scanf("%d", &numFiles);
File files[numFiles];
allocateLinked(files, numFiles);
deallocateLinked(files, numFiles);
return 0;
}
Output:
Result:
Thus to implement Linked File Allocation Strategy using c is successfully executed and verified.
Ex. No : 15 A FIRST COME FIRST SERVE (FCFS) DISK SCHEDULING ALGORITHM
Date :
Aim:
Algorithm:
Program:
#include<stdio.h>
#include<stdlib.h>
int abs(int a) {
return a >= 0 ? a : -a;
}
int main() {
int n, head, i;
int *requests;
int totalSeek = 0;
printf("Path: ");
printf("%d ", head);
for(i = 0; i < n; i++) {
totalSeek += abs(requests[i] - head);head =
requests[i];
printf("%d ", head);
}
printf("\n");
printf("Total seek time: %d\n", totalSeek);free(requests);
return 0;
}
Output:
Result:
Thus to implement FCFS Disk Scheduling Algorithm using c is successfullyexecuted and verified.
Ex. No : 15 B SHORTEST SEEK TIME FIRST (SSTF) DISK SCHEDULING ALGORITHM
Date :
Aim:
Algorithm:
Program:
#include<stdio.h>
#include<stdlib.h>
#include<limits.h>
int abs(int a) {
return a >= 0 ? a : -a;
}
return index;
}
int main() {
int n, head, i;
int *requests;
int totalSeek = 0;
int *visited = (int *)calloc(n, sizeof(int));
printf("Path: ");
printf("%d ", head);
printf("\n");
printf("Total seek time: %d\n", totalSeek);
free(requests);
free(visited);
return 0;
}
Output:
Result:
Thus to implement SSTF Disk Scheduling Algorithm using c is successfullyexecuted and verified.
Ex. No : 16 INSTALLATION OF LINUX USING VMWARE
Date :
Aim:
3) Open the VMWare player application. MAKE SURE TO RUN THE PROGRAM AS AN
ADMINISTRATOR. Click on Create a New Virtual Machine.
4) Choose install from Installer disc image file (iso) and browse for the Ubuntu .iso you just
downloaded. Click Next.
5) Enter the required information then click Next.
6) Enter a name you wish to use for the virtual machine, or you may leave it as is. Click Next.
9) If you are prompted to install VMWare tools, then go ahead and do so.
12) After successfully installing the driver, your new virtual machine should be fully set up!
Result: This installation of LINUX using VMware is successfully executed and verified.