Skip to content

Instantly share code, notes, and snippets.

View projjal1's full-sized avatar
💭
Software Developer

Projjal Gop projjal1

💭
Software Developer
View GitHub Profile
@projjal1
projjal1 / fifo.c
Created May 13, 2020 13:38
FIFO Page Replacement Algorithm Implementation in C
#include<stdio.h>
void fifo(int string[20],int n,int size)
{
//Creating array for block storage
int frames[n];
//Initializing each block with -1
for (int i=0;i<n;i++)
frames[i]=-1;
@projjal1
projjal1 / lru.c
Created May 13, 2020 13:40
LRU (Least Recently Used) Page Replacement Algorithm implmentation in C
#include<stdio.h>
void lru(int string[20],int n,int size)
{
//Creating array for block storage
int frames[n];
//Initializing each block with -1
for (int i=0;i<n;i++)
frames[i]=-1;
@projjal1
projjal1 / optimal.c
Created May 13, 2020 13:42
Optimal Page Replacement Algorithm Implementation in C
#include<stdio.h>
void optimal(int string[20],int n,int size)
{
//Creating array for block storage
int frames[n];
//Initializing each block with -1
for (int i=0;i<n;i++)
frames[i]=-1;
@projjal1
projjal1 / fifo_belady.c
Created May 13, 2020 13:43
Fifo Page Replacement Algorithm to show Belady's Anomaly
#include<stdio.h>
void fifo(int string[20],int n,int size)
{
//Creating array for block storage
int frames[n];
//Initializing each block with -1
for (int i=0;i<n;i++)
frames[i]=-1;
@projjal1
projjal1 / best_fit.c
Created May 13, 2020 13:44
Best Fit Memory Management in C
#include <stdio.h>
void bestFit(int blockSize[],int m,int processSize[],int n)
{
//Block allocations for process
int allocation[n];
//Initially allocate the index of -1 to all allocation blocks
for (int i=0;i<n;i++)
{
@projjal1
projjal1 / first_fit.c
Created May 13, 2020 13:44
First Fit memory management scheme in C
#include <stdio.h>
void firstFit(int blockSize[],int m,int processSize[],int n)
{
//Block allocations for process
int allocation[n];
//Initially allocate the index of -1 to all allocation blocks
for (int i=0;i<n;i++)
{
@projjal1
projjal1 / next_fit.c
Created May 13, 2020 13:45
Next Fit Memory Management scheme in C
#include <stdio.h>
void nextFit(int blockSize[],int m,int processSize[],int n)
{
//Block allocations for process
int allocation[n];
//Initially allocate the index of -1 to all allocation blocks
for (int i=0;i<n;i++)
{
@projjal1
projjal1 / worst_fit.c
Created May 13, 2020 13:45
Worst Fit Memory Management Scheme in C
#include <stdio.h>
void worstFit(int blockSize[],int m,int processSize[],int n)
{
//Block allocations for process
int allocation[n];
//Initially allocate the index of -1 to all allocation blocks
for (int i=0;i<n;i++)
{
@projjal1
projjal1 / producer_consumer.c
Created May 13, 2020 16:25
Write a program to implement Producer- Consumer problem using semaphores.
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <unistd.h>
#include <pthread.h>
#include <semaphore.h>
pthread_t *producers;
pthread_t *consumers;
@projjal1
projjal1 / dining_philosopher.py
Created May 13, 2020 16:26
Write a program to implement Dining Philosopher problem using monitor.
#!/usr/bin/env python3
from threading import Thread, Condition, RLock
import time
# state
HUNGRY = 0
EATING = 1
THINKING = 2
#Monitor class