0% found this document useful (0 votes)
132 views

Advanced Computing Lab Manual

Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
132 views

Advanced Computing Lab Manual

Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 49

Advanced Computing Lab

ADVANCED COMPUTING
LAB MANUAL

For M.Tech I Year I Semester


(R-19)

Academic Year 2020-21

By

M Naresh Babu

1 SRK INSTITUTE OF TECHNOLOGY


Advanced Computing Lab

Course Objectives:
From the course the student will learn
 The student should have hands on experience in using various sensors like temperature,
humidity, smoke, light, etc. and should be able to use control web camera, network, and
relays connected to the Pi.
Course Outcomes:
After the completion of the course, student will be able to
 The student should have hands on experience in using various sensors like temperature,
humidity, smoke, light, etc. and should be able to use control web camera, network, and
relays connected to the Pi.
 Development and use of s IoT technology in Societal and Industrial Applications.
 Skills to undertake high quality academic and industrial research in Sensors and IoT.
 To classify Real World IoT Design Constraints, Industrial Automation in IoT.
Experiment 1: Start Raspberry Pi and try various Linux commands in command terminal
window: ls, cd, touch, mv, rm, man, mkdir, rmdir, tar, gzip, cat, more, less, ps, sudo, cron,
chown, chgrp, ping etc.

Experiment 2: Study and Install IDE of Arduino and different types of Arduino.

Experiment 3: Study and Implement Zigbee Protocol using Arduino / RaspberryPi.

Experiment 4: Write a map reduce program that mines weather data. Weather sensors
collecting data every hour at many locations across the globe gather a large volume of log
data, which is a good candidate for analysis with Map Reduce, since it is semi structured and
record-oriented.

Experiment 5: Data analytics using Apache Spark on Amazon food dataset, find all the pairs
of items frequently reviewed together.
Write a single Spark application that
 Transposes the original Amazon food dataset, obtaining a PairRDD of the
type<user_id>→ <list of the product_ ids reviewed by user_id>
 Counts the frequencies of all the pairs of products reviewed together.
 Writes on the output folder all the pairs of products that appear more than once and their
frequencies. The pairs of products must be sorted by frequency.

Experiment 6:
Write a program to Implement Bankers algorithm for Dead Lock Avoidance.

Experiment 7:
Write a program to Producer-consumer problem Using semaphores.

Experiment 8:
Write a program for an image enhancement using pixel operation.

Experiment 9:
Write a Program to enhance image using image arithmetic and logical operations.

Experiment 10:
Write a program of bit stuffing used by Data Link Layer.

2 SRK INSTITUTE OF TECHNOLOGY


Advanced Computing Lab

Experiment 11:
Write a program to configure a Network using Distance Vector Routing protocol.

Experiment 12:
Write a program to perform the function oriented diagram: DFD and Structured chart.

Experiment 13:
Write a program to perform the system analysis: Requirement analysis, SRS.

Experiment 14:
Write a program to draw the structural view diagram: Class diagram, object diagram.

Experiment 15:
Write C programs for implementing the Demorgan’s law.

CONTENT BEYOND SYLLABUS:

16. To write a C program to implement memory management using paging technique

17. To write a C program to implement memory management using segmentation technique

3 SRK INSTITUTE OF TECHNOLOGY


Advanced Computing Lab

1. Raspberry PI Various LINUX Commands

Aim: To Start Raspberry Pi and working with various Linux commands in command
terminal window: ls, cd, touch, mv, rm, man, mkdir, rmdir, tar, gzip, cat, more, less, ps, sudo,
cron, chown, chgrp, ping etc.

The terminal (or 'command-line') on a computer allows a user a great deal of control over
their system (or in this case, Pi!). Users of Windows may already have come across
Command Prompt or Powershell and Mac OS users may be familiar with Terminal. All of
these tools allow a user to directly manipulate their system through the use of commands.
These commands can be chained together and/or combined together into complex scripts (see
the linux usage page on scripting) that can potentially complete tasks more efficiently than
much larger traditional software packages.

Opening a Terminal window


On the Raspberry Pi (running Raspbian), the default terminal application is LXTerminal. This
is known as a 'terminal emulator', this means that it emulates the old style video terminals
(from before graphical user interfaces were developed) in a graphical environment. The
application can be found on the Raspberry Pi desktop and when started will look something
like this:

Terminal screenshot
You should be able to see the following prompt:

pi@raspberrypi ~ $

This shows your username and the hostname of the Pi. Here the username is pi and the
hostname is raspberrypi
Now, let's try running a command. Type pwd (present working directory) followed by the
Enter key. This should display something like /home/pi

Navigating and browsing your Pi


One of the key aspects of using a terminal is being able to navigate your file system. Firstly,
run the following command: ls -la. You should see something similar to:

ls result
The ls command lists the contents of the directory that you are currently in (your present
working directory). The -la component of the command is what's known as a 'flag'. Flags
modify the command that's being run. In this case the l displays the contents of the directory
in a list, showing data such as their sizes and when they were last edited, and the a displays
all files, including those beginning with a ., known as 'dotfiles'. Dotfiles usually act as
configuration files for software and as they are written in text, they can be modified by
simply editing them.

In order to navigate to other directories the change directory command, cd, can be used. You
can specify the directory that you want to go to by either the 'absolute' or the 'relative' path.
So if you wanted to navigate to the python_games directory, you could either do cd
/home/pi/python_games or just cd python_games (if you are currently in /home/pi). There are

4 SRK INSTITUTE OF TECHNOLOGY


Advanced Computing Lab

some special cases that may be useful: ~ acts as an alias for your home directory, so
~/python_games is the same as /home/pi/python_games; . and .. are aliases for the current
directory and the parent directory respectively, e.g. if you were in /home/pi/python_games, cd
.. would take you to /home/pi

History and auto-complete


Rather than type every command, the terminal allows you to scroll through previous
commands that you've run by pressing the up or down keys on your keyboard.

If you are writing the name of a file or directory as part of a command then pressing tab will
attempt to auto-complete the name of what you are typing. For example, if you have a file in
a directory called aLongFileName then pressing tab after typing a will allow you to choose
from all file and directory names beginning with a in the current directory, allowing you to
choose aLongFileName

Sudo
Some commands that make permanent changes to the state of your system require you to
have root privileges to run. The command sudo temporarily gives your account (if you're not
already logged in as root) the ability to run these commands, provided your user name is in a
list of users ('sudoers'). When you append sudo to the start of a command and press enter you
will be asked for your password, if that is entered correctly then the command you want to
run will be run using root privileges. Be careful though, some commands that require sudo to
run can irreparably damage your system so be careful!

Further information on sudo and the root user can be found on the linux root page

Installing software using apt


You can use the apt command to install software in Raspbian. This is the 'package manager'
that is included with any Debian-based Linux distributions (including Raspbian). It allows
you to install and manage new software packages on your Pi. In order to install a new
package, you would type sudo apt install <package-name> (where <package-name> is the
package that you want to install). Running sudo apt update will update a list of software
packages that are available on your system. If a new
version of a package is available, then sudo apt full-upgrade will update any old packages to
the new version. Finally, sudo apt remove <package-name> removes or uninstalls a package
from your system
More information about this can be found in the Linux usage section on apt

Other useful commands

There are a few other commands that you may find useful, these are listed below:
cp makes a copy of a file and places it at the specified location (essentially doing a 'copy-
paste'), for example - cp file_a /home/other_user/ would copy the file file_a from your home
directory to that of the user other_user (assuming you have permission to copy it there). Note
that if the target is a folder, the filename will remain the same, but if the target is a filename,
it will give the file the new name
mv moves a file and places it at the specified location (so where cp performs a 'copy-paste',
mv performs a 'cut-paste'). The usage is similar to cp, so mv file_a /home/other_user/ would

5 SRK INSTITUTE OF TECHNOLOGY


Advanced Computing Lab

move the file file_a from your home directory to that of the specified user. mv is also used to
rename a file, i.e. move it to a new location, e.g. mv hello.txt story.txt
rm removes the specified file (or directory when used with -r). Warning: Files deleted in this
way are generally not restorable

mkdir: This makes a new directory, e.g. mkdir new_dir would create the directory new_dir
in the present working directory
cat lists the contents of files, e.g. cat some_file will display the contents of some_file
Other commands you may find useful can be found in the commands page
Finding out about a command
To find out more information about a particular command then you can run the man followed
by the command you want to know more about (e.g. man ls). The man-page (or manual page)
for that command will be displayed, including information about the flags for that program
and what effect they have. Some man-pages will give example usage

6 SRK INSTITUTE OF TECHNOLOGY


Advanced Computing Lab

2. Study and Installation of Arduino UNO

Aim: To Study and Install IDE of Arduino and different types of Arduino.

This document explains how to connect your Uno board to the computer and upload your
first sketch. The Arduino Uno is programmed using the Arduino Software (IDE), our
Integrated Development Environment common to all our boards and running both online and
offline. For more information on how to get started with the Arduino Software visit
the Getting Started page

Use your Arduino Uno on the Arduino Web IDE


Use your Arduino Uno on the Arduino Desktop IDE
Install the board drivers
Open your first sketch
Select your board type and port
Upload the program
Learn more on the Desktop IDE

Use your Arduino Uno on the Arduino Web IDE


All Arduino boards, including this one, work out-of-the-box on the Arduino Web Editor, no
need to install anything

The Arduino Web Editor is hosted online, therefore it will always be up-to-date with the
latest features and support for all boards. Follow this simple guide to start coding on the
browser and upload your sketches onto your board

Use your Arduino Uno on the Arduino Desktop IDE


If you want to program your Arduino Uno while offline you need to install the Arduino
Desktop IDE The Uno is programmed using the Arduino Software (IDE), our Integrated
Development Environment common to all our boards. Before you can move on,
you must have installed the Arduino Software (IDE) on your PC, as explained in the home
page of our Getting Started

Connect your Uno board with an A B USB cable; sometimes this cable is called a USB
printer cable
The USB connection with the PC is necessary to program the board and not just to power it
up. The Uno automatically draw power from either the USB or an external power supply.
Connect the board to your computer using the USB cable. The green power LED
(labelled PWR) should go on

Install the board drivers


If you used the Installer, Windows - from XP up to 10 - will install drivers automatically as
soon as you connect your board

If you downloaded and expanded the Zip package or, for some reason, the board wasn't
properly recognized, please follow the procedure below

Click on the Start Menu, and open up the Control Panel

7 SRK INSTITUTE OF TECHNOLOGY


Advanced Computing Lab

While in the Control Panel, navigate to System and Security. Next, click on System. Once the
System window is up, open the Device Manager
Look under Ports (COM & LPT). You should see an open port named "Arduino UNO
(COMxx)". If there is no COM & LPT section, look under "Other Devices" for "Unknown
Device"
Right click on the "Arduino UNO (COmxx)" port and choose the "Update Driver Software"
option

Next, choose the "Browse my computer for Driver software" option


Finally, navigate to and select the driver file named "arduino.inf", located in the "Drivers"
folder of the Arduino Software download (not the "FTDI USB Drivers" sub-directory). If you
are using an old version of the IDE (1.0.3 or older), choose the Uno driver file
named "Arduino UNO.inf"
Windows will finish up the driver installation from there
See also: step-by-step screenshots for installing the Uno under Windows XP
Open your first sketch
Open the LED blink example sketch: File > Examples >01.Basics > Blink

Select your board type and port


You'll need to select the entry in the Tools > Board menu that corresponds to your Arduino
board

8 SRK INSTITUTE OF TECHNOLOGY


Advanced Computing Lab

Select the serial device of the board from the Tools | Serial Port menu. This is likely to
be COM3 or higher (COM1 and COM2 are usually reserved for hardware serial ports). To
find out, you can disconnect your board and re-open the menu; the entry that disappears
should be the Arduino board. Reconnect the board and select that serial port.

Upload the program


Now, simply click the "Upload" button in the environment. Wait a few seconds - you should
see the RX and TX leds on the board flashing. If the upload is successful, the message "Done
uploading." will appear in the status bar

9 SRK INSTITUTE OF TECHNOLOGY


Advanced Computing Lab

A few seconds after the upload finishes, you should see the pin 13 (L) LED on the board start
to blink (in orange). If it does, congratulations! You've gotten Arduino up-and-running. If
you have problems, please see the troubleshooting suggestions

Learn more on the Desktop IDE


See this tutorial for a generic guide on the Arduino IDE with a few more infos on the
Preferences, the Board Manager, and the Library Manager
Now that you have set up and programmed your Uno board, you may find inspiration in
our Project Hub tutorial platform or have a look to the tutorial pages that explain how to use
the various features of your board
examples for using various sensors and actuators reference for the Arduino language

Last revision 2019/10/16 by SM


The text of the Arduino getting started guide is licensed under a Creative Commons
Attribution-ShareAlike 3.0 License. Code samples in the guide are released into the public
domain

10 SRK INSTITUTE OF TECHNOLOGY


Advanced Computing Lab

11 SRK INSTITUTE OF TECHNOLOGY


Advanced Computing Lab

3. Zigbee Implementation Using Arduino

Aim: To Study and Implement Zigbee Protocol using Arduino

ZigBee is a wireless technology which provides connection between the devices. It is the
only open global standard to fulfill the needs of low cost, low power wireless network used
for device monitoring and control. The ZigBee standard is based on IEEE 802.15.4. It
operates in ISM (Industrial, Scientific, and Medical) radio bands which include 2.4 GHz, 784
MHz, 868MHz and 915 MHz. Data rate varies from 20 Kb/s to 250 Kb/s. It supports all
network topologies such as star,tree and mesh topology. Its transmission distance is limited to
10 to 100 meters line of sight. It depends on power output and environmental factors. It can
use long distance communication using intermediate devices. The data is passed through the
mesh network of intermediate devices and it reaches the distant devices. The devices are
secured by 128 bit symmetric encryption keys. So the networking is secure. ZigBee also
provides long battery life, so it can last for several years. It can be used in several
applications such as wireless light switches, smart grid, medical devices etc. It is simpler and
less expensive than Bluetooth, Wi-Fi etc. XBee and other XBee enabled devices provide
connection to several other devices

Arduino
It is a simple microcontroller board. It is an open source computing platform and has an
environment for developing software for the Arduino board. It can be used to make
computers. It is used to create interactive projects. It takes input from sensors or switches and
controls the outputs. Arduino boards are inexpensive compared to other microcontroller
based devices. It can stand-alone or can communicate with the software of the
computer. Arduino software can run on Windows, Linux and Macintosh OSX. It provides an
Integrated Development Environment (IDE) which is written on Java for programming
microcontrollers. It supports C, C++ programming languages. So anyone who knows the
basic programming C can easily access Arduino IDE. It is very simple. Arduino has built-in
functions. It can access serial port. It does not need to access the register details. It can simply
call the functions and easily perform the functions. So the coding and debugging are fast and
efficient. Arduino IDE displays the data which is into and out of the serial port

Interfacing ZigBee with Arduino


It is very easy to interface the ZigBee with Arduino. Before interfacing, the user must know
about the series. Series one is better for beginners. It can communicate with communication
devices, sensors etc. If two ZigBee modules are of same types, then they can communicate
with each other. To achieve communication between two ZigBee, first one ZigBee is
connected to Arduino and the other ZigBee is connected to sensor, microcontroller or
computer. There is no need of additional electronics to connect the ZigBee with Arduino.
After that, configuration is set on two modules. The below figure shows the interfacing of
ZigBee with Arduino. The supply voltage of module is regulated to 5V and 3.3V. The VCC
of ZigBee module is connected to 3.3V of Arduino and GND of ZigBee is connected to the
GND of Arduino. The figure shows that the transmitter and receiver pin of ZigBee is
connected to the transmitter and receiver pin of Arduino. Using Arduino board, the ZigBee
module can be connected with the microcontroller

12 SRK INSTITUTE OF TECHNOLOGY


Advanced Computing Lab

Configuration of ZigBee
To configure the ZigBee
First the ZigBee module must be connected to the computer using its serial adapter
For windows, puTTy or virtual terminal must be downloaded
The serial port of computer is set to 9600 baud rate, 8 data bits, 1 stop bit and no parity
Then click on the LOCAL ECHO BOX and click OK
The time session must be saved. Then click the CONNECT button of virtual terminal
After connection with ZigBee, the name of session is given
After these steps; the connection is occurred with the ZigBee module

To configure the ZigBee module, AT commands can also be used


The procedures given above can be used to configure other ZigBee modules if required.
Connect the other ZigBee module with the serial port of the computer. Then repeat the
procedure above. After that; two ZigBee modules can communicate with each other

Steps to Interface ZigBee with Arduino


Step 1:- Run the X-Ctu software to configure the ZigBee module
Step 2:- The ZigBee modules can communicate via Arduino boards using the code. A simple
code for sending serial data is given below
Step 3: Code
void setup( ) // Initialization settings; then only runs the function
{
Serial.begin(9600); //baudrate is setup to 9600
}
void loop( ) //The function operates repeatedly until the poweroff
{
while(serial.available( ) )
{
serial.write(serial.read( ));// Check whether data is available or not. If data is
available, then data is read
}
}

The above code helps the ZigBee module to work according to the instructions sent by
Arduino. In the same way the ZigBee modules can receive instructions from other ZigBee
module also. For this case, the instructions or data is received from one ZigBee and this data
is sent through the serial pins of the Arduino. For that, one of the ZigBee must be connected
with the Arduino, and then the code which is given above is loaded to Arduino. After
uploading the code to the Arduino board, the Arduino board can be connected with the other
ZigBee module. After these all steps, the ZigBee modules can communicate with each other

13 SRK INSTITUTE OF TECHNOLOGY


Advanced Computing Lab

14 SRK INSTITUTE OF TECHNOLOGY


Advanced Computing Lab

Arduino

Interfacing Zigbee with Arduino

15 SRK INSTITUTE OF TECHNOLOGY


Advanced Computing Lab

4. Map Reduce Program

Aim: To write a map reduce program that mines weather data. Weather sensors collecting
data every hour at many locations across the globe gather a large volume of log data, which is
a good candidate for analysis with Map Reduce, since it is semi structured and record-
oriented

Resources:

VMWare, Web browser, 4 GB RAM, Hard Disk 80 GB

PROGRAM LOGIC:

WordCount is a simple program which counts the number of occurrences of each word in a
given text input data set. WordCount fits very well with the MapReduce programming model
making it a great example to understand the Hadoop Map/Reduce programming style. Our
implementation consists of three main parts

1. Mapper
2. Reducer
3. Main program

Step-1. Write a Mapper

A Mapper overrides the ―map function from the Class


"org.apache.hadoop.mapreduce.Mapper" which provides pairs as the input. A Mapper
implementation may output pairs using the provided Context . Input value of the WordCount
Map task will be a line of text from the input data file and the key would be the line number .
Map task outputs for each word in the line of text.

Pseudo-code

void Map (key, value)


{
for each max_temp x in value:
output.collect(x, 1);
}
void Map (key, value)
{
for each min_temp x in value:
output.collect(x, 1);
}

Step-2 Write a Reducer

A Reducer collects the intermediate output from multiple map tasks and assemble a single
result. Here, the WordCount program will sum up the occurrence of each word to pairs as
<word, occurrence>

16 SRK INSTITUTE OF TECHNOLOGY


Advanced Computing Lab

Pseudo-code
void Reduce (max_temp,<list of value>)
{
for each x in<list of value>:
sum+=x;
final_output.collect(max_temp, sum);
}
void Reduce (min_temp,<list of value )
{
for each x in <list of value>:
sum+=x;
final_output.collect(min_temp, sum);
}
3. Write Driver
The Driver program configures and run the MapReduce job. We use the main program to
perform basic configurations such as:
Job Name : name of this Job Executable (Jar)
Class: the main executable class. For here, WordCount.
Mapper Class: class which overrides the "map" function. For here, Map.
Reducer: class which override the "reduce" function. For here , Reduce.

17 SRK INSTITUTE OF TECHNOLOGY


Advanced Computing Lab

5. Data Analytics using Apache Spark

Aim: Data analytics using Apache Spark on Amazon food dataset, find all the pairs of items
frequently reviewed together. To write a single Spark application that Transposes the original
Amazon food dataset, obtaining a PairRDD of the type<user_id>→<list of the product_ ids
reviewed by user_id> Counts the frequencies of all the pairs of products reviewed together.
Writes on the output folder all the pairs of products that appear more than once and their
frequencies. The pairs of products must be sorted by frequency

In this lab, we continue our work on the Amazon dataset, using Apache Spark. Your task is
given the original Amazon food dataset, find all the pairs of items frequently reviewed
together

Apache Spark is an open-source, distributed processing system commonly used for big data
workloads

The input Amazon food dataset (available in the HFDS shared folder of the BigData@Polito
cluster: /data/students/bigdata-01QYD/Lab3/Reviews.csv) lists all the reviews per-row (one
review per line), and is comma-separated. In each line, two of the columns represent the user
id and product id. The schema of Reviews.csv is the following:

Id,ProductId,UserId,ProfileName,HelpfulnessNumerator,HelpfulnessDenominator,Score,Tim
e,Summary,Text Inspect the output of your application to search for interesting facts, and
analyze the job execution as usual (performances, number of executors, etc…).

Pay attention that the line starting with “Id,” is the header of the file and must not be
considered. On the web site you can download the file ReviewsSample.csv. It contains a
sample of Reviews.csv. You can use it to perform some initial tests locally.

Bonus task

Extend the implemented application in order to write on the standard output the top 10, most
frequent, pairs and their frequencies.

Note that Spark 1.6, or above, provides the following actions that can be applied on an RDD
of type JavaRDD<T>:

1) List <T> top(int n, java.util.Comparator comp)


2) List <T>take Ordered (int n, java.util.Comparator comp) top returns the n largest elements
of the RDD based on the specified Comparator takeOrdered returns the n smallest elements
of the RDD based on the specified Comparator Note that the standard output of the driver is
stored in the log files of your application.

Use the following steps top access the log files.

How to access logs by using the job history web page The logs of your applications on the
cluster is available at https://ma1-bigdata.polito.it:18489/ If there is any error and you need to
analyze the content of the error log files follow these
steps:

18 SRK INSTITUTE OF TECHNOLOGY


Advanced Computing Lab

1. Open a new terminal on your local machine (do not use the previous terminal
connected to bigdatalab.polito.it).

2. On the local terminal command line, type the command kinit sXXXXXX (then, you
will be asked for your BigDataLab password) This command is used to obtain a
Kerberos ticket (without it you cannot access the log web page)
3. Now you should have access to the spark job history and logs at https://ma1-
bigdata.polito.it:18489/
4. Select your job and click on its App ID You can use the search box to select only your
jobs
5. Click on the executor tab and analyze the stderr associated with you application. Pay
attention that there is one log file for the driver and one log file for each executor. If
you application raised an exception, analyze all the stderr files to identify the reason
of the error (depending on the error type, the log containing the needed information
can be the one associated with the driver or that of an executor)

How to access logs without the web page and the Kerberos ticket

If you are connecting from outside Polito, and hence


1) you cannot request a Kerberos ticket and
2) you cannot access the history web page, you can proceed as follows to retrieve the log files
from the command line:

1. Open a shell on the gateway by using ssh ssh [email protected]


2. Execute the following command in the remote shell: yarn logs -applicationId
application_1521819176307_2195 The last parameter is the application/job ID. You
can retrieve the job ID of your application on the HUE interface:
https://bigdatalab.polito.it:8080/hue/jobbrowser#!jobs

19 SRK INSTITUTE OF TECHNOLOGY


Advanced Computing Lab

6. Bankers Algorithm for Dead Lock Avoidance

Aim: To write a program to Implement Bankers algorithm for Dead Lock Avoidance

Program:
#include<stdio.h>
struct file
{
int all[10];
int max[10];
int need[10];
int flag;
};
int main()
{
struct file f[10];
int fl;
int i,j,k,p,b,n,r,g,cnt=0,id,newr;
int avail[10],seq[10];
printf("Enter number of processes--");
scanf("%d",&n);
printf("Enter number of resources--");
scanf("%d",&r);
for(i=0;i<n;i++)
{
printf("Enter details for P%d",i);
printf("\nEnter allocation\t--\t");
for(j=0;j<r;j++)
scanf("%d",&f[i].all[j]);
printf("EnterMax\t\t--\t");
for(j=0;j<r;j++)
scanf("%d",&f[i].max[j]);
f[i].flag=0;
}
printf("\nEnter Available Resources\t--\t");
for(i=0;i<r;i++)
scanf("%d",&avail[i]);
printf("\nEnter New Request Details--");
printf("\nEnter pid\t--\t");
scanf("%d",&id);
printf("Enter Request for Resources\t--\t");
for(i=0;i<r;i++)
{
scanf("%d",&newr);
f[id].all[i]+=newr;
avail[i]=avail[i]-newr;
}
for(i=0;i<n;i++)

20 SRK INSTITUTE OF TECHNOLOGY


Advanced Computing Lab

for(j=0;j<r;j++)
{
f[i].need[j]=f[i].max[j]-f[i].all[j];
if(f[i].need[j]<0)
f[i].need[j]=0;
}
}
cnt=0;
fl=0;
while(cnt!=n)
{
g=0;
for(j=0;j<n;j++)
{
if(f[j].flag==0)
{
b=0;
for(p=0;p<r;p++)
{
if(avail[p]>=f[j].need[p])
b=b+1;
else
b=b-1;
}
if(b==r)
{
printf("\nP%disvisited",j);
seq[fl++]=j;
f[j].flag=1;
for(k=0;k<r;k++)
avail[k]=avail[k]+f[j].all[k];
cnt=cnt+1;
printf("(");
for(k=0;k<r;k++)
printf("%3d",avail[k]);
printf(")");
g=1;
}
}
}
if(g==0)
{
printf("\nREQUESTNOTGRANTED--DEADLOCKOCCURRED");
printf("\nSYSTEM IS IN UNSAFE STATE");
goto y;
}
}

21 SRK INSTITUTE OF TECHNOLOGY


Advanced Computing Lab

printf("\nSYSTEMISINSAFESTATE");
printf("\nTheSafeSequenceis--(");
for(i=0;i<fl;i++)
printf("P%d",seq[i]);

printf(")");
y: printf("\nProcess\t\tAllocation\t\tMax\t\t\tNeed\n");
for(i=0;i<n;i++)
{
printf("P%d\t",i);
for(j=0;j<r;j++)
printf("%6d",f[i].all[j]);
for(j=0;j<r;j++)
printf("%6d",f[i].max[j]);
for(j=0;j<r;j++)
printf("%6d",f[i].need[j]);
printf("\n");
}
return 0;
}

Output:
Enter number of processes--5
Enter number of resources--3
Enter details for P0
Enter allocation -- 010
EnterMax -- 753
Enter details for P1
Enter allocation -- 200
EnterMax -- 322
Enter details for P2
Enter allocation -- 302
EnterMax -- 902
Enter details for P3
Enter allocation -- 211
EnterMax -- 222
Enter details for P4
Enter allocation -- 002
EnterMax -- 433

Enter Available Resources -- 332

Enter New Request Details--


Enter pid -- 1
Enter Request for Resources -- 102

P1isvisited( 5 3 2)
P3isvisited( 7 4 3)
P4isvisited( 7 4 5)

22 SRK INSTITUTE OF TECHNOLOGY


Advanced Computing Lab

P0isvisited( 7 5 5)
P2isvisited( 10 5 7)
SYSTEM IS IN SAFE STATE
The Safe Sequenceis--(P1P3P4P0P2)
Process Allocation Max Need
P0 0 1 0 7 5 3 7 4 3
P1 3 0 2 3 2 2 0 2 0
P2 3 0 2 9 0 2 6 0 0
P3 2 1 1 2 2 2 0 1 1
P4 0 0 2 4 3 3 4 3 1

23 SRK INSTITUTE OF TECHNOLOGY


Advanced Computing Lab

7. Producer-consumer problem Using semaphores

Aim: To write a program to Producer-consumer problem Using semaphores

Program:

#include<stdio.h>
int main()
{
int buffer[10],bufsize,in,out,produce,consume,choice=0;
in=0;
out=0;
bufsize=10;
while(choice!=3)
{
printf("\n1.Produce\t2.Consume\t3.Exit");
printf("\nEnteryourchoice:");
scanf("%d",&choice);
switch(choice)
{
case 1:if((in+1)%bufsize==out)
printf("\nBufferisFull");
else
{
printf("\nEnter the value:");
scanf("%d",&produce);
buffer[in]=produce;
in=(in+1)%bufsize;
}
break;
case 2:if(in==out)
printf("\nBuffer is Empty");
else
{
consume=buffer[out];
printf("\nThe consumed value is:%d",consume);
out=(out+1)%bufsize;
}
break;
}
}
return 0;
}

24 SRK INSTITUTE OF TECHNOLOGY


Advanced Computing Lab

Output:

1.Produce 2.Consume 3.Exit


Enteryourchoice:2

Buffer is Empty
1.Produce 2.Consume 3.Exit
Enteryourchoice:1

Enter the value:100

1.Produce 2.Consume 3.Exit


Enteryourchoice:2

The consumed value is:100


1.Produce 2.Consume 3.Exit
Enteryourchoice:3

25 SRK INSTITUTE OF TECHNOLOGY


Advanced Computing Lab

8. Image enhancement using pixel operation

Aim: To write a program for an image enhancement using pixel operation

Program:

package ocv;
import org.opencv.core.Core;
import org.opencv.core.Mat;
import org.opencv.imgcodecs.Imgcodecs;
import org.opencv.imgproc.Imgproc;
public class Main
{
public static void main( String[] args )
{
try
{
// For proper execution of native libraries
// Core.NATIVE_LIBRARY_NAME must be loaded before
// calling any of the opencv methods
System.loadLibrary( Core.NATIVE_LIBRARY_NAME );
//input image
Mat source = Imgcodecs.imread("E:\\input.jpg",

Imgcodecs.CV_LOAD_IMAGE_GRAYSCALE);
Mat destination = new Mat(source.rows(),
source.cols(), source.type());
// applying histogram equalization
Imgproc.equalizeHist(source, destination);
// writing output image
Imgcodecs.imwrite("E:\\output.jpg", destination);
}
catch (Exception e)
{
System.out.println("error: " + e.getMessage());
}
}
}

26 SRK INSTITUTE OF TECHNOLOGY


Advanced Computing Lab

9. Enhance image using image arithmetic and logical operations

Aim: To write a Program to enhance image using image arithmetic and logical operations

Program:

Addition of two images using python


import cv2
import numpy as np

# path to input images are specified and


# images are loaded with imread command
image1 = cv2.imread('input1.jpg')
image2 = cv2.imread('input2.jpg')

# cv2.addWeighted is applied over the


# image inputs with applied parameters
weightedSum = cv2.addWeighted(image1, 0.5, image2, 0.4, 0)

# the window showing output image


# with the weighted sum
cv2.imshow('Weighted Image', weightedSum)

# De-allocate any associated memory usage


if cv2.waitKey(0) & 0xff == 27:
cv2.destroyAllWindows()

27 SRK INSTITUTE OF TECHNOLOGY


Advanced Computing Lab

Input(i):

Input(ii):

Output:

Subtraction of pixels of two images using python

28 SRK INSTITUTE OF TECHNOLOGY


Advanced Computing Lab
import cv2
import numpy as np

# path to input images are specified and


# images are loaded with imread command
image1 = cv2.imread('input1.jpg')
image2 = cv2.imread('input2.jpg')

# cv2.subtract is applied over the


# image inputs with applied parameters
sub = cv2.subtract(image1, image2)

# the window showing output image


# with the subtracted image
cv2.imshow('Subtracted Image', sub)

# De-allocate any associated memory usage


if cv2.waitKey(0) & 0xff == 27:
cv2.destroyAllWindows()

Input(i)

Image(2)

Output:

29 SRK INSTITUTE OF TECHNOLOGY


Advanced Computing Lab

10.Bit stuffing used by Data Link Layer

Aim: To write a program of bit stuffing used by Data Link Layer

Program:

#include<stdio.h>
#include<conio.h>
#include<string.h>
int main()
{
int a[20],b[30],i,j,k,count,n;
printf("Enter frame size (Example: 8):");
scanf("%d",&n);
printf("Enter the frame in the form of 0 and 1 :");
for(i=0; i<n; i++)
scanf("%d",&a[i]);
i=0;
count=1;
j=0;
while(i<n)
{
if(a[i]==1)
{
b[j]=a[i];
for(k=i+1; a[k]==1 && k<n && count<5; k++)
{
j++;
b[j]=a[k];
count++;
if(count==5)
{
j++;
b[j]=0;
}
i=k;
}
}
else
b[j]=a[i];
i++;
j++;
}
printf("After Bit Stuffing :");
for(i=0; i<j; i++)
printf("%d",b[i]);
return 0;
}

30 SRK INSTITUTE OF TECHNOLOGY


Advanced Computing Lab

Output

Enter frame size (Example: 8):12


Enter the frame in the form of 0 and 1 :0 1 0 1 1 1 1 1 1 0 0 1
After Bit Stuffing :0101111101001

31 SRK INSTITUTE OF TECHNOLOGY


Advanced Computing Lab

11.Distance Vector Routing Protocol

Aim: To write a program to configure a Network using Distance Vector Routing protocol
Program:
#include<stdio.h>
struct node
{
unsigned dist[20];
unsigned from[20];
}rt[10];
int main()
{
int costmat[20][20];
int nodes,i,j,k,count=0;
printf("\nEnter the number of nodes : ");
scanf("%d",&nodes);//Enter the nodes
printf("\nEnter the cost matrix :\n");
for(i=0;i<nodes;i++)
{
for(j=0;j<nodes;j++)
{
scanf("%d",&costmat[i][j]);
costmat[i][i]=0;
rt[i].dist[j]=costmat[i][j];//initialise the distance equal to cost
matrix
rt[i].from[j]=j;
}
}
do
{
count=0;
for(i=0;i<nodes;i++)
for(j=0;j<nodes;j++)
for(k=0;k<nodes;k++)
if(rt[i].dist[j]>costmat[i][k]+rt[k].dist[j])
{
rt[i].dist[j]=rt[i].dist[k]+rt[k].dist[j];
rt[i].from[j]=k;
count++;
}
}while(count!=0);
for(i=0;i<nodes;i++)
{
printf("\n\n For router %d\n",i+1);
for(j=0;j<nodes;j++)
printf("\t\nnode %d via %d Distance %d ",j+1,rt[i].from[j]+1,rt[i].dist[j]);
}
printf("\n\n");
return 0;}

32 SRK INSTITUTE OF TECHNOLOGY


Advanced Computing Lab

Output

Enter the number of nodes : 3

Enter the cost matrix :


027
201
710

For router 1

node 1 via 1 Distance 0


node 2 via 2 Distance 2
node 3 via 2 Distance 3

For router 2

node 1 via 1 Distance 2


node 2 via 2 Distance 0
node 3 via 3 Distance 1

For router 3

node 1 via 2 Distance 3


node 2 via 2 Distance 1
node 3 via 3 Distance 0

33 SRK INSTITUTE OF TECHNOLOGY


Advanced Computing Lab

12. Performing function oriented diagram

Aim: To perform the function oriented diagram: DFD and Structured chart

Function Oriented Design:


Function Oriented design is a method to software design where the model is decomposed into
a set of interacting units or modules where each unit or module has a clearly defined function.
Thus, the system is designed from a functional viewpoint.

Data Flow Diagram:


Data-flow design is concerned with designing a series of functional transformations that
convert system inputs into the required outputs. The design is described as data-flow
diagrams. These diagrams show how data flows through a system and how the output is
derived from the input through a series of functional transformations.

Data-flow diagrams are a useful and intuitive way of describing a system. They are generally
understandable without specialized training, notably if control information is excluded. They
show end-to-end processing. That is the flow of processing from when data enters the system
to where it leaves the system can be traced.

Data-flow design is an integral part of several design methods, and most CASE tools support
data-flow diagram creation. Different ways may use different icons to represent data-flow
diagram entities, but their meanings are similar

The notation which is used in DFD is based on the following symbols:

Data Dictionaries:
A data dictionary lists all data elements appearing in the DFD model of a system. The data
items listed contain all data flows and the contents of all data stores looking on the DFDs in
the DFD model of a system.

34 SRK INSTITUTE OF TECHNOLOGY


Advanced Computing Lab

A data dictionary lists the objective of all data items and the definition of all composite data
elements in terms of their component data items. For example, a data dictionary entry may
contain that the data grossPay consists of the parts regularPay and overtimePay.
grossPay = regularPay + overtimePay
For the smallest units of data elements, the data dictionary lists their name and their type.
A data dictionary plays a significant role in any software development process because of the
following reasons:
o A Data dictionary provides a standard language for all relevant information for use by
engineers working in a project. A consistent vocabulary for data items is essential
since, in large projects, different engineers of the project tend to use different terms to
refer to the same data, which unnecessarily causes confusion.
o The data dictionary provides the analyst with a means to determine the definition of
various data structures in terms of their component elements.

Data Flow Diagram:


The report generator produces a report which describes all of the named entities in a data-
flow diagram. The user inputs the name of the design represented by the diagram. The report
generator then finds all the names used in the data-flow diagram. It looks up a data dictionary
and retrieves information about each name. This is then collated into a report which is output
by the system.

Structured Charts:
It partitions a system into block boxes. A Black box system that functionality is known to
the user without the knowledge of internal design.

Structured Chart is a graphical representation which shows:


o System partitions into modules
o Hierarchy of component modules
o The relation between processing modules
o Interaction between modules
o Information passed between modules

The following notations are used in structured chart:

35 SRK INSTITUTE OF TECHNOLOGY


Advanced Computing Lab

13. Performing system analysis

36 SRK INSTITUTE OF TECHNOLOGY


Advanced Computing Lab

Aim: To perform the system analysis: Requirement analysis, SRS

Program:
Software requirement is a functional or non-functional need to be implemented in the system.
Functional means providing particular service to the user.
For example, in context to banking application the functional requirement will be when
customer selects "View Balance" they must be able to look at their latest account balance.
Software requirement can also be a non-functional, it can be a performance requirement. For
example, a non-functional requirement is where every page of the system should be visible to
the users within 5 seconds.
So, basically software requirement is a
● Functional or
● Non-functional
Analyze Requirements:
Consider example of an educational software system where a student can register for
different courses.
Lets study how to analyze the requirements. The requirements must maintain a standard
quality of its requirement, different types of requirement quality includes
● Atomic
● Uniquely identified
● Complete
● Consistent and unambiguous
● Traceable
● Prioritized
● Testable

System Requirements Specification:

A System Requirements Specification (SRS) (also known as a Software Requirements


Specification) is a document or set of documentation that describes the features and behavior
of a system or software application. It includes a variety of elements (see below) that attempts
to define the intended functionality required by the customer to satisfy their different users.
SRS Includes:

A purpose
An overall description
Specific requirements

Why we use an SRS document:


A software requirements specification is the basis for your entire project. It lays the
framework that every team involved in development will follow.

It’s used to provide critical information to multiple teams — development, quality assurance,
operations, and maintenance. This keeps everyone on the same page.

37 SRK INSTITUTE OF TECHNOLOGY


Advanced Computing Lab

Using the SRS helps to ensure requirements are fulfilled. And it can also help you make
decisions about your product’s lifecycle — for instance, when to retire a feature.

Writing an SRS can also minimize overall development time and costs. Embedded
development teams especially benefit from using an SRS.

Here are five steps you can follow to write an effective SRS document.
1. Create an Outline (Or Use an SRS Template) Your first step is to create an outline for
your software requirements specification. ...
2. Start With a Purpose. ...
3. Give an Overview of What You'll Build. ...
4. Detail Your Specific Requirements. ...
5. Get Approval for the SRS.

14. Drawing structural view diagram

38 SRK INSTITUTE OF TECHNOLOGY


Advanced Computing Lab

Aim: To write a program to draw the structural view diagram: Class diagram, object diagram

Class Diagram:
⮚ It shows a set of classes, interfaces, and collaborations and their relationships.
⮚ Graphically a class diagram is a collection of vertices and arcs. The relationships used
here are dependency, generalization, association, aggregation.
(i) Dependency:
❖ It is using relationship. Change in one thing may effect in another thing.
❖ Graphically rendered by dashed directed line.

(ii) Generalization:
❖ It is a “is-a-kind-of” relationship. Relationship between general thing and specific
thing (or) Relationship between super class and sub class.
❖ Graphically rendered solid directed line with a large open arrowhead.

(iii) Association:
❖ It is a structural relationship. Objects of one thing are connected to objects of
another thing. Graphically rendered by solid line.

(iv) Aggregation:
❖ It is a structural relationship. It is defined as whole / part relationship.
❖ Graphically rendered as directed line with open diamond shape at one end.

(v) Realization:
❖ It is a semantic relationship. One classifier specifies a contract and another classifier
guarantees to carry out that contract.
❖ Graphically rendered as dashed directed line with a large open arrow head.

Structural diagrams:
❖ These diagrams are static.
❖ There are four structural diagrams
1. Class diagram:
❖ It specifies classes, interfaces, collaborations and relationships
2. Object diagram:
❖ It specifies objects and relationships
3. Component diagram:
❖ It specifies components and relationships
4. Deployment diagram:
❖ It specifies Runtime processing nodes and relationships

39 SRK INSTITUTE OF TECHNOLOGY


Advanced Computing Lab

Object Diagram:

⮚ An object diagram is a diagram that shows a set of objects and their relationships.
⮚ Graphically an object diagram is a collection of vertices and arcs. It represents objects
and links.
⮚ The object diagram is shown below

40 SRK INSTITUTE OF TECHNOLOGY


Advanced Computing Lab

15. Implementing Demorgan’s Law

Aim: To write C programs for implementing the Demorgan’s law

Program:
#include <stdio.h>
#include <math.h>
int main()
{
int a,b,g,i,j,x,y;
char ch = 'y';
do
{
puts("\nShow that (!(x < 5) && !(y >= 7)) and !((x < 5) || (y >= 7)) are
logically equivalent\n\n");
printf("%s", "Enter x: ");
scanf("%2u", &x);
printf("%s", "Enter y: ");
scanf("%2u", &y);
if ((!(x < 5) && !(y >= 7)) && !((x < 5) || (y >= 7)))
printf("%s", "True!\n\n");
else
printf("%s", "False!\n\n");
printf("%s", "Want more examples of this logical equivalency? ");
getchar();
scanf("%c", &ch);
}
while (ch == 'y');
if (ch == 'n')
{
do
{
puts("\nShow that (!(a == b) || !(g != 5)) and !((a == b) && (g != 5))
are logically equivalent\n\n");
printf("%s", "Enter a: ");
scanf("%2u", &a);
printf("%s", "Enter b: ");
scanf("%2u", &b);
printf("%s", "Enter g: ");
scanf("%2u", &g);
if ((!(a == b) || !(g != 5)) && !((a == b) && (g != 5)))
printf("%s", "True!\n\n");
else
printf("%s", "False!\n\n");
printf("%s", "Want more examples of this logical equivalency? ");
getchar();
scanf("%c", &ch);
}
while(ch == 'y');

41 SRK INSTITUTE OF TECHNOLOGY


Advanced Computing Lab

if (ch == 'n')
{
do
{
puts("\nShow that !((x <= 8) && (y > 4)) and (!(x <= 8) || !(y > 4)) are
logically equivalent\n\n");
printf("%s", "Enter x: ");
scanf("%2u", &x);
printf("%s", "Enter y: ");
scanf("%2u", &y);
if (!((x <= 8) && (y > 4)) && (!(x <= 8) || !(y > 4)))
printf("%s", "True!\n\n");
else
printf("%s", "False!\n\n");
printf("%s", "Want more examples of this logical equivalency? ");
getchar();
scanf("%c", &ch);
}
while (ch == 'y'); // choose yes to continue with current part, or no to move on
}
if (ch == 'n')
{
do
{
puts("\nShow that !((i > 4) || (j <= 6)) and (!(i > 4) && !(j <= 6)) are
logically equivalent\n\n");
printf("%s", "Enter i: ");
scanf("%2u", &i);
printf("%s", "Enter j: ");
scanf("%2u", &j);
if (!((i > 4) || (j <= 6)) && (!(x <= 8) && !(y > 4)))
printf("%s", "True!\n\n");
else
printf("%s", "False!\n\n");
printf("%s", "Want more examples of this logical equivalency? ");
getchar();
scanf("%c", &ch);
}
while (ch == 'y');
}
if (ch == 'n')
printf("\n%s", "Now you know DeMorgan's Laws!");
return 0;
}

42 SRK INSTITUTE OF TECHNOLOGY


Advanced Computing Lab

Output
Show that (!(x < 5) && !(y >= 7)) and !((x < 5) || (y >= 7)) are logically equivalent

Enter x: 5
Enter y: 7
False!

Want more examples of this logical equivalency? y

Show that (!(x < 5) && !(y >= 7)) and !((x < 5) || (y >= 7)) are logically equivalent

Enter x: 2
Enter y: 9
False!

Want more examples of this logical equivalency? y

Show that (!(x < 5) && !(y >= 7)) and !((x < 5) || (y >= 7)) are logically equivalent

Enter x: 5
Enter y: 6
False!

Want more examples of this logical equivalency? y

Show that (!(x < 5) && !(y >= 7)) and !((x < 5) || (y >= 7)) are logically equivalent

Enter x: 8
Enter y: 6
True!

Want more examples of this logical equivalency? n

Show that (!(a == b) || !(g != 5)) and !((a == b) && (g != 5)) are logically equivalent

Enter a: 4
Enter b: 4
Enter g: 5
True!

Want more examples of this logical equivalency? n

43 SRK INSTITUTE OF TECHNOLOGY


Advanced Computing Lab

Show that !((x <= 8) && (y > 4)) and (!(x <= 8) || !(y > 4)) are logically equivalent

Enter x: 3
Enter y: 5
False!

Want more examples of this logical equivalency? y

Show that !((x <= 8) && (y > 4)) and (!(x <= 8) || !(y > 4)) are logically equivalent

Enter x: 2
Enter y: 6
False!

Want more examples of this logical equivalency? n

Show that !((i > 4) || (j <= 6)) and (!(i > 4) && !(j <= 6)) are logically equivalent

Enter i: 4
Enter j: 5
False!

Want more examples of this logical equivalency? y

Show that !((i > 4) || (j <= 6)) and (!(i > 4) && !(j <= 6)) are logically equivalent

Enter i: 6
Enter j: 7
False!

Want more examples of this logical equivalency? n

Now you know DeMorgan's Laws!

44 SRK INSTITUTE OF TECHNOLOGY


Advanced Computing Lab

EXPERIMENT 8:
AIM: To write a C program to implement memory management using paging technique
SOURCE CODE:
#include <stdio.h>
#include<unistd.h>
void main()
{
int b[20],n,i,pa,p,a,d;
printf(“\nProgram for
paging”); scanf(“%d”,&n);
printf(“\nEnter the base
address:”); for(i=0;i<n;i++)
{
scanf(“%d”,&b[i]);
}
printf(“\nEnter the logical
address:”); scanf(“%d”,&p);
for(i=0;i<n;i++)
{
if(i==p)
{
pa=
b[i]
+d;
a=b[
i];
printf(“\n\tPageNo.\t BaseAdd. PhysicalAdd. \n\t %d \t %d \t
%d \t ”,p,a,pa);
}
}
printf(“\nInvalid page”);
}
OUTPUT
Program for paging
Enter the number of
pages:2 Enter the
base address:
100
150
Enter the Logical
address:50 Enter the
page number:1

Sample Output 1:
PageNo.
BaseAdd.PhysicalAdd. 1
150 200

45 SRK INSTITUTE OF TECHNOLOGY


Advanced Computing Lab

Sample Input 2:
Program for paging
Enter the number of
pages:1 Enter the
base address:
100
Enter the Logical
address:2 Enter the
page number:2

Sample Output 2:
Invalid page.

46 SRK INSTITUTE OF TECHNOLOGY


Advanced Computing Lab

EXPERIMENT 9:
AIM: To write a C program to implement memory management using segmentation
SOURCE CODE:
#include <stdio.h>
#include<unistd.h>
void main()
{
int b[20],l[20],n,i,pa,s,a,d; printf(“\
nProgram for segmentation”);
printf(“\nEnter the number of
segments:”); scanf(“%d”,&n);
printf(“\nEnter the base address and limit
register:”); for(i=0;i<n;i++)
{
scanf(“%d”,&b[i]);
scanf(“%d”,&l[i])
}
printf(“\nEnter the logical
address:”); scanf(“%d”,&d);
for(i=0;i<n;i++)
{
if(i==s)
{
if(d<l[i])
{
pa=
b[i]
+d;
a=b[
i];
printf(“(“\n\tPageNo.\t BaseAdd. PhysicalAdd. \n\t %d \t %d \t%d \t ”,s,a,pa); exit(0);
}
Else
{
Printf(“\n
Pagesize exceeds”);
exit(0);
}}}
Printf(“Invalid
segment”);
}

OUTPUT:
Sample Input 1:
Program for
segmentation Enter the
number ofsegments:3
Enter the base address and limit register:
100 50

47 SRK INSTITUTE OF TECHNOLOGY


Advanced Computing Lab

150 20
130 34
Enter the Logical
address:25
Enter the segment
number:1
Sample Output 1:
PageNo. BaseAdd.
PhysicalAdd.
2 130 155
Sample Input 2:
Program for
segmentation Enter the
number ofsegments:2
Enter the Logical address and limit register:
100 50
150 20
Enter the logical
address:25 Enter the
segment number:1
Sample Output 2:
page size exceeds

48 SRK INSTITUTE OF TECHNOLOGY


Advanced Computing Lab

49 SRK INSTITUTE OF TECHNOLOGY

You might also like