CPU Scheduling Algorithms and Memory Management Techniques

CPU Scheduling FCFS

#include

#include

#include

void main()

{

int i,j,n,bt[10],compt[10],at[10],

wt[10],tat[10]; float

sumwt=0.0,sumtat=0.0,avgwt,avgtat;

printf(“Enter number of processes: “);

scanf(“%d”,&n);

printf(“Enter the burst time of %d process\n”,

n); for(i=0;i

{

scanf(“%d”,&bt[i]);

}

printf(“Enter the arrival time of %d process\n”,

n); for(i=0;i

{

scanf(“%d”,&at[i]);

}

compt[0]=bt[0]-at[0];

for(i=1;i

compt[i]=bt[i]+compt[i-

1]; for(i=0;i

{

tat[i]=compt[i]-at[i];

wt[i]=tat[i]-bt[i];

sumtat+=tat[i];

sumwt+

Read More

Java Development: JSP, Spring, and Containerization

In JavaServer Pages (JSP), there are several building blocks that make up the structure of a web application:

1. Directives

Directives provide global information about an entire JSP page. There are three types of directives:

Page Directive

Provides instructions to the container about how the page should be processed. Common attributes include language, contentType, import, etc.

Include Directive

Includes the contents of another file (such as HTML or JSP) into the current JSP file at translation time.

Taglib

Read More

Java Programming Examples: Strings, Recursion, File I/O, and More

1. String Concatenation

String str1 = “Hello”;
String str2 = “world”;
// Using the + operator
String concatenatedString = str1 + “, ” + str2;
// Using the concat() method
String concatenatedString2 = str1.concat(“, “).concat(str2);
System.out.println(concatenatedString);
System.out.println(concatenatedString2);

2. Recursion Examples

public class RecursionExamples {
    // Factorial using recursion
    public static int factorial(int n) {
        if (n == 0 || n == 1) {
            return 1;
   
Read More

Introduction to Computer Science and Programming

This document provides an overview of object-oriented program design, computer memory, machine language, and the software development life cycle.

  • The Von Neumann computer model consists of a CPU and memory.
  • Computer memory is made up of cells with unique addresses and stores information in binary format.
  • Machine language is the binary code that computers can understand.
  • High-level programming languages like Python and Java are used to write programs that are easier for humans to understand.
  • Compilers
Read More

Understanding Multi-Layer Network Models: OSI & Internet

Multi-Layer Network Models

Most Important Network Models: OSI & Internet

Open Systems Interconnection Model (OSI)

Created by ISO as a framework.

7 Layers

Internet Model

Created by DARPA in 1970.

Made to solve problems of internetworking.

5 Layers

Based on Transmission Control Protocol (TCP/IP)

OSI Model Layers

7 – Application Layer: Set of utilities used by application programs.

6 – Presentation Layer: Formats data for presentation to the user.

5 – Session Layer: Initiates, maintains, and terminates each

Read More

Divide and Conquer Algorithms in C: Merge Sort, Quick Sort, Fractional Knapsack, Kruskal’s, Prim’s, LCS, N-Queens, and Rabin-Karp

Merge Sort using Divide and Conquer

C Code

#include
void merge(int a[], int beg, int mid, int end)
{
int i, j, k;
int n1 = mid – beg + 1;
int n2 = end – mid;
int LeftArray[n1], RightArray[n2];
for (int i = 0; i < n1; i++)
LeftArray[i] = a[beg + i];
for (int j = 0; j < n2; j++)
RightArray[j] = a[mid + 1 + j];
i = 0;
j = 0;
k = beg;
while (i < n1 && j < n2)
{
if(LeftArray[i] <= RightArray[j])
{
a[k] = LeftArray[i];
i++;
}
else
{
a[k] = RightArray[j];
j++;
}
k++;
}
while (i{
a[k] = LeftArray[i];
i++;
k++;
}
while

Read More