Posts

Showing posts from November, 2023

Java slips solution SEM 5 tybsc cs

 Java Slips Click here to view the link I will upload the slips as I solve it.  Slip Count: 13

WebTech 30 slips solution 2023 TYBSC computer science

 WebTech 30 slips solution 2023     TYBSC SEM 5 Click Here to view the slips Frome the above link you can view the codes. (all codes expect bootstrap)  1. WebTech slips:  first you have to change the .txt => .html / .php according to the code inside the file 2. For FDS slips: you need jupyter notebook on your PC to view the files. 

Least Recently Used (LRU) page algorithm in c

Exploring MRU Page Replacement Algorithm in C TheLazyBusyCoder's Blog Welcome to my coding adventures! In this post, we'll explore a C program. Least Recently Used page algo in C Watch this video for explanation #include<stdio.h> #include<stdbool.h> bool find(int frame[] , int framesize , int cur) { int i; for(i = 0; i = 0; j--) { if(cur == arr[j]) break; } if(j

MRU page replacement algorithm

Exploring MRU Page Replacement Algorithm in C TheLazyBusyCoder's Blog Welcome to my coding adventures! In this post, we'll explore a C program. Most Recently Used page algo in C Watch this video for explanation #include<stdio.h> #include<stdbool.h> bool find(int frame[] , int framesize , int cur) { int i; for(i = 0; i = 0; j--) { if(cur == arr[j]) break; } if(j > max) { max = j; rep = i; } } return rep; } void mru(int arr[] , int n , int framesize) { int frame[framesize]; int i; int hit = 0; int pf = 0; for(i = 0; i

LFU Page Replacement Algorithm in C

Exploring LFU Page Replacement Algorithm in C TheLazyBusyCoder's Blog Welcome to my coding adventures! In this post, we'll explore a C program. Optimal Page Replacement(OPT) in C The page which has less frequency gets replaced #include <stdio.h> #include<stdbool.h> typedef struct Frame { int p , f , t; } Frame; void display(Frame frame[] , int framesize , bool isHit) { int i; for(i = 0; i < framesize; i++) { printf("%2d | " , frame[i].p); } if(isHit == true) printf(" HIT\n"); else printf(" *\n"); } bool find(Frame frame[] , int framesize, int cur) { int i = 0; for(i = 0; i < framesize; i++) { if(frame[i].p == cur) return true; } return false; } int replace(Frame frame[] , int framesize) { int i; for(i = 0; i < framesize; i++) if(frame[i].p == -1) return...

Optimal Page Replacement (OPT) in C

Exploring Optimal Page Replacement Algorithm in C TheLazyBusyCoder's Blog Welcome to my coding adventures! In this post, we'll explore a C program. Optimal Page Replacement(OPT) in C Check out YouTube video explaining theory: Watch now #include <stdio.h> int find(int frame[], int frameSize , int cur) { int i; for(i = 0; i max) { max = j; rep = i; } } return rep; } void opt(int ref[] , int framesize , int n) { int frame[framesize]; int i; for(i = 0; i

Most Frequently Used Page Replacement (MFU) in C

Exploring MRU Algorithm in C TheLazyBusyCoder's Blog Welcome to my coding adventures! In this post, we'll explore a C program. Most Frequently Used Page Replacement (MFU) in C Page with maximum frequency get replaced #include <stdio.h> #include <stdlib.h> #include<stdbool.h> typedef struct Frame { int p , f , t; } Frame; void display(Frame frame[] , int framesize , bool isHit) { int i; for(i = 0; i frame[rep].f) { rep = i; } else if(frame[i].f == frame[rep].f) { if(frame[i].t

FIFO Page Replacement Algorithm

Exploring FIFO Page Replacement Algorithm in C TheLazyBusyCoder's Blog Welcome to my coding adventures! In this post, we'll explore a C program. FIFO Page Replacement Algorithm in C Check out my YouTube video explaining this code: Watch now #include <stdio.h> int find(int frame[] , int framesize , int cur) { int i; for(i = 0; i

OS Assignment 2 MyShell to do file operations

Custom shell in C TheLazyBusyCoder's Blog Welcome to my coding adventures! In this post, we'll explore a C program. Write a C program to implement the toy shell. It should display the command prompt “myshell$”. Tokenize the command line and execute the given command by creating the child process. Additionally it should interpret the following commands. count c filename :- To print number of characters in the file. count w filename :- To print number of words in the file. count l filename :- To print number of lines in the file. #include <unistd.h> #include <fcntl.h> #include <stdio.h> #include <string.h> #include <sys/wait.h> // seperate sentence: "count c filename" => count , c , filename void make_toks(char *s, char *tok[]) { int i = 0; char *p; p = str...

Round Robin Scheduling algorithm in C

Round Robin Algorithm in C TheLazyBusyCoder's Blog Welcome to my coding adventures! In this post, we'll explore a C program. Round Robin - scheduling algorithm in C Check out my YouTube video: Watch now #include <stdio.h> #include <stdlib.h> #include <string.h> typedef struct process { int id , at , bt , ct , tat, wt , rt; } process; typedef struct queue { int pro; } queue; queue root[50]; int front = 0; int rare = 0; void push(int id) { root[rare].pro = id; rare++; } int pop() { if(front == rare) return -1; int temp = root[front].pro; front++; return temp; } int isEmpty() { if(front == rare) return 1; return 0; } void sortAT(process pro[], int n) { process temp; for(int i = 0; i pro[j + 1].at) { temp = pro[j]; pro[j] = pro[j + 1]; pro[j + 1] = temp; } } void display(process ...

Exploring Preemptive Priority Algorithm in C

Exploring Preemptive Priority Algorithm in C TheLazyBusyCoder's Blog Welcome to my coding adventures! In this post, we'll explore a C program. Preemptive Priority - scheduling algorithm in C Check out my YouTube video explaining this code: Watch now #include <stdio.h> #include <stdlib.h> typedef struct process { int id, at, bt, ct, wt, tat, rt , p; } process; void sortID(process pro[], int n) { process temp; for (int i = 0; i pro[j + 1].id) { temp = pro[j]; pro[j] = pro[j + 1]; pro[j + 1] = temp; } } void sortP(process pro[], int n) { process temp; for (int i = 0; i pro[j + 1].p) { temp = pro[j]; pro[j] = pro[j + 1]; pro[j + 1] = temp; } } void display(process pro[], int n) { printf("\n\nTABLE:\n"); for (int...

Non Preemptive Priority Algorithm in C

Exploring Non Preemptive Priority Algorithm in C TheLazyBusyCoder's Blog Welcome to my coding adventures! In this post, we'll explore a C program. Exploring Non Preemptive Priority - scheduling algorithm in C Check out my YouTube video explaining this code: No Video #include <stdio.h> #include typedef struct process { int id , at , bt ,p,rt, ct , tat , wt; } process; void display(process proc[] , int n) { int i; printf("\n\nP AT BT P CT TAT WT\n"); for(i = 0; i 0) { int min = -1; for(i = 0; i 0) { if(min == -1 || proc[i].p

Preemptive Shortest Job First (SJF) - scheduling algorithm in C

Exploring Preemptive SJF Algorithm in C TheLazyBusyCoder's Blog Welcome to my coding adventures! In this post, we'll explore a C program. Preemptive Shortest Job First (SJF) - scheduling algorithm in C Check out my YouTube video explaining this code: Watch now #include <stdio.h> #include <stdlib.h> typedef struct process { int id, at, bt, ct , wt, tat, rt; } process; void display(process pro[], int n) { printf("P AT BT CT TAT WT \n"); for (int i = 0; i 0) { int min = -1; for(i = 0; i 0) { if(min == -1 || proc[i].rt

Non Preemptive SJF scheduling algorithm in C

Non Preemptive SJF scheduling algorithm in C.  This is a working code with output. If you want the explanation for this code, you can view: this video YouTube Link #include <stdio.h> typedef struct process { int id , at , bt ,rt, ct , tat , wt; } process; void display(process proc[] , int n) { int i; printf("\n\nP AT BT CT TAT WT\n"); for(i = 0; i 0) { int min = -1; for(i = 0; i 0) { if(min == -1 || proc[i].rt

FCFS scheduling algorithm in C (Operating Systems)

FCFS scheduling algorithm in C.  Its working code with output If you want explanation, you can view my YouTube video.  Youtube Link #include <stdio.h> #include <stdlib.h> typedef struct process { int id, at, bt, wt, tat, ct; } process; void sort(process pro[], int n) { process temp; for (int i = 0; i pro[j + 1].at) { temp = pro[j]; pro[j] = pro[j+1]; pro[j+1] = temp; } } void display(process pro[], int n) { printf("\n"); for (int i = 0; i