Lab 4
Lab 4
LAB 4
1. Suppose a process page table contains the entries shown below. Using the format shown in
Figure 6.17a, indicate where the process pages are located in memory.
0 1 1
1 * 0
2 0 1
3 3 1
4 * 0
5 * 0
6 2 1
7 * 0
0
1 0
2
1
3
4 2
5 3
6
7
The virtual page 0 is mapped to frame 1 in the physical memory, as illustrated in the
preceding picture, since the valid bit is 1.
Because the valid bit for virtual page 1 is zero, the process's page is now not in
physical memory.
The page is mapped to frame 0 in the physical memory since the valid bit for virtual
page 2 is 1.
The page is mapped to frame 3 in physical memory because the valid bit
corresponds to virtual page 3.
The pages of the processes are now not in physical memory since the valid bits
correspond to virtual pages 4 and 5.
The page is mapped to frame 2 in the physical memory since the valid bit for virtual
page 6 is 1.
Because the valid bit for virtual page 7 is zero, the process's page is now not in
physical memory
2. Suppose we have 210 bytes of virtual memory and 28 bytes of physical main memory.
Suppose the page size is 24 bytes.
a) How many pages are there in virtual memory?
Size of virtual memory / size of page = the number of pages in virtual memory
= 210 / 24 = 26
b) How many page frames are there in main memory?
Size of physical memory / Size of page = Number of pages in physical memory
= 28 / 24
= 2(8-4)= 24 page frames
c) How many entries are in the page table for a process that uses all of virtual memory?
Page offset = 4 bits
Number of virtual memory needed = 10 bits
10-4 = 6
26 entries
3. A system implements a paged virtual address space for each process using a one-level page
table. The maximum size of virtual address space is 16MB. The page table for the running
process includes the following valid entries (the → notation indicates that a virtual page maps to
the given page frame, that is, it is located in that frame):
The page size is 1024 bytes and the maximum physical memory size of the machine is 2MB.
a) How many bits are required for each virtual address?
virtual address space=16 MB (220 . 24)
There are 24 address lines and 24 bits in use.
b) How many bits are required for each physical address?
virtual address space=2 MB (220. 21)
There are 21 address lines and 21 bits in use.
c) What is the maximum number of entries in a page table?
maximum number of entries in a page table = (virtual m space /page size)
=224/210
= 214 entries
4. Under What circumstances is it desirable to collect groups of processes and programs into
subsystems running on a large computer? What advantages would there be to creating logical
partitions on this system?
If the processes share a set of resources, it may be beneficial to organize them
together as a subsystem.
It's a good idea to group processes and programs into subsystems because if a certain
set of processes is used to test the system and anything strange happens, such as a
system crash, only the subsystem in which the processes are executing would be
affected.
If a certain set of individuals is granted restricted access to limited resources for a
short period of time, it may be useful to organize the user processes as a subsystem as
well.
Advantages include:
• Subsystems cannot offer low-level segmentation of the machine and its resources. This is
accomplished by adding LPARs to a subsystem.
• Each subsystem creates a logically different environment that can be handled and
adjusted independently.
5. Discuss the following questions relative to compilers:
a. Which phase a compiler would give you syntax error?
The exical analyzer phase complains about variables that aren't specified.
A lexical analyzer is a computer program that divides a string of letters into lexemes
and generates a list of tokens. These tokens include language-specific reserve words,
literals, operators, and programmer-defined variables. A symbol table for variables
and procedure names is built in this step. It raises an error if any of the variables are
undefined.
b. Which phase complains about undefined variables?
Undefined variables are a problem at the lexical analyzer phase.
A lexical analyzer is a computer program that divides a string of letters into lexemes
and generates a list of tokens. These tokens include language-specific reserve words,
literals, operators, and programmer-defined variables. A symbol table for variables
and procedure names is built in this step. It raises an error if any of the variables are
undefined.
c. If you try to add an integer to character string, which compiler would emit the error
message?
When a programmer tries to add an integer to a character string, the semantic
analyzer phase generates an error message.
A syntax tree is supplied to a semantic analyzer as input from the syntactic analysis
phase.
This step examines the program for semantic flaws and type checking. When a type
mismatch occurs, this phase displays an error message.
6. Java is called an interpreted language, yet Java is a compiled language that produces a binary
output stream. Explain how this language can be both compiled and interpreted.
• First, the java source file is compiled, resulting in a class file with byte code.
• This is not an executable byte code.
• The Java virtual machine loads this byte code (class file) (JVM).
• It checks the class file format in the Java virtual machine. • After that, the interpreter
analyzes the class files and generates the target machine code.
• When the target machine code is created, the execution begins.