How Do You Visualize Computer Memory Computer Science Essay

Published:

This essay has been submitted by a student. This is not an example of the work written by our professional essay writers.

Main memory is a large array of words or bytes. Each word or byte has its own address. For a program to be executed, it must be mapped to absolute addresses and loaded into memory. The operating system is responsible for the following activities in connection with memory management.

Keep track of which parts of memory are currently being used and by whom.

Decide which processes are to be loaded into memory when memory space becomes available.

Allocate and deallocate memory space as needed.

Address Binding

Usually a program resides on a disk as a binary executable file. The program must be brought into memory and placed in a process for it to be executed. Addresses in the source program are generally symbolic (such as count). A compiler will typically bind

these symbolic addresses to relocatable addresses (such as "14 bytes from the beginning of this module")

. The linkage editor or loader will in turn bind these relocatable addresses to absolute addresses (such as 74014). Each binding is a mapping from one address space to another. Classically, the binding of instructions and data to memory addresses can be done at any step along the way:

Compile time: If it is known at compile time where the process will reside in memory, then absolute can be generated.

Load time: if it is known at compile time where the process will reside in the memory, the compiler must generate relocatable code. In this case, final binding is delayed until load time.

Execution time/Run time: If the process can be moved during execution from one memory segment to another, then binding must be delayed until runtime. Special hardware must be available for this scheme to work.

Logical Vs Physical address space

An address generated by the CPU is commonly referred to as a logical address, whereas an address as seen by the memory unit (that is, the one loaded into the memory address register

MAR of the memory) is commonly referred to as a physical address. The compile time and load-time address binding schemes result in an environment where the logical and physical addresses are the same. However, the execution-time address binding scheme results in an environment where the logical and physical addresses differ. The set of all logical addresses generated by a program is referred to as a logical address space; the set of all physical addresses corresponding to these logical addresses is referred to as physical address space. The run-time mapping from virtual to physical address is done by the memory-management unit (MMU), which is a hardware device.

Operating Systems - Main memory management 2

CONTIGUOUS ALLOCATION

Single partition allocation

The memory is divided into two partitions, one for the resident operating system, and one for the user process.

Dynamic relocation using relocation register

Operating Systems - Main memory management 3

Multiple partition allocation

Fixed partition

Memory is divided into a no. of fixed sized partitions. Each partition may contain exactly one process. When a partition is free, a process is selected from the input Queue and is loaded into a free partition.

Variable partition

Initially all memory is available for user processes, and is considered as large block of available memory. When a process arrives and needs memory, we search for a hole large enough for this process and allocate only as much.

External and Internal Fragmentation

Multiple partition allocation schemes suffer from external fragmentation. As processes are loaded and removed from the memory, the free memory space is broken into little pieces. External fragmentation exists when enough total memory space exists to satisfy a request, but it is not contiguous; storage is fragmented into a number of holes. Internal fragmentation is memory that is internal to a partition, but is not being used.

Ques2. State the method of mapping physical address from logical address. Differentiate between virtual and physical address space.

Ans:- We can map the physical address from logical address by using a relocation register together with a limit register. The relocation register contains the value of the smallest physical address space, the limit register contains the range of logical addresses(for example, relocation=100040 and limit =74600). With relocation and limit registers, each logical address must be less than the limit register, the MMU maps the logical address dynamically by adding the value of relocation register. This mapped address is then sent to memory.

Difference between virtual and physical address space is given below:-

Physical address Space

Virtual Address Space

1. Physical Memory is from the hardware called RAM.

1. The virtual memory is exactly the word virtual which means it's not real, because it uses the space in the hard disk to create some memory space.

2. The computer hardware that is the primary memory system of a computer also called as RAM is the physical memory.

2. Virtual memory is a memory management technique, used by multitasking computer operating systems wherein non-contiguous memory is presented to software as contiguous memory. This contiguous memory is referred to as the virtual address space.

3. RAM is the amount of physical memory installed on your computer. It acts like short-term memory, enabling programs to load and operate faster.

3. Windows makes up the difference for that amount of RAM requirement by allocating or reserving a portion of your hard drive to act as though it were RAM. That's what is referred to as virtual memory.

4. Physical memory is limited to our size of RAM. In reality it is something less than that because some address space has to be allocated to memory mapped devices.

4. Virtual memory is logical and physical memory is the actual available memory.

Each running process has its own virtual address space. But each virtual memory mapped either to RAM or Hard disk by the MMU(Memory Management Unit).So by virtual memory systems the computer overcomes its physical memory limitations.

Ques3. Consider any example of your choice and based upon that compare different page replacement algorithms.

Ans:- Page Replacement Algorithms:-

Want lowest page-fault rate

Evaluate algorithm by running it on a particular string of memory references (reference string) and computing the number of page faults on that string

In all our examples, the reference string is

1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5

First In First Out:-

Reference string: 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5

3 frames (3 pages can be in memory at a time per process)

1

2

3

4 frames

1

2

3

4 1

2

3

4

Optimal Algorithm:-

Replace page that will not be used for longest period of time

4 frames example

1

2

3 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5

How do you know this?

Used for measuring how well your algorithm performs

Reference string: 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5

Least Recently Used Algorithm:-

Reference string: 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5

1

1

1

1

5

2

2

2

2

2

3

5

5

4

4

4

4

3

3

3

Stack implementation - keep a stack of page numbers in a double link form:

Page referenced:

move it to the top

requires 6 pointers to be changed

No search for replacement

Counter implementation

Every page entry has a counter; every time page is referenced through this entry, copy the clock into the counter

When a page needs to be changed, look at the counters to determine which are to change

Counter implementation

Every page entry has a counter; every time page is referenced through this entry, copy the clock into the counter

When a page needs to be changed, look at the counters to determine which are to change

PART2

Ques4. Identify different types of files available in different operating systems. Define file and explain operation performed on file.

Ans: - A common technique for implementing file types is to include the type as part of the file name. The name is split in to two parts- a name and an extension, usually separated by a period character. File name examples includes resume.doc, server.java and ReaderThread.c.

Some common file types are given in following table:-

A file is named collection of related information that is recorded on secondary storage. In general, a file is a sequence of bits, bytes, lines, or records, the meaning of which is created by the file's creator and user.

A file is an abstract data type. To define a file properly, we need to consider the operations that can be performed on files. The operating system can provide system calls to create, write, read, reposition, delete, and truncate files.

Creating a file- Two steps are necessary to create a file. First, space in the file system must be found for the file. Second, an entry for the new file must be made in the directory.

Writing a file- To write a file, we make a system call specifying both the name of a file and the information to be written to the file. Given the name of the file, the system searches the directory to find the file's location. The system must keep a write pointer to the location in the file where the next write is to take place.

Reading a file- To read from a file, we use a system call that specifies the name of the file and where the next block of the file should be put. Again, the directory is searched for the associated entry, and the files need to keep the read pointer to the location in the file where the next read is to take place.

Repositioning within a file- The directory is searched for the appropriate entry, and the current file-position pointer is repositioned to a given value. Repositioning within a file need not involve any actual I/O. This file operation is known as a file seek.

Deleting a file- To delete a file, we search the directory for the named file. Having found the associated directory entry, we release all the file space, so that it can be reused by other files, and erase the directory entry.

Truncating a file- The user may want to erase the contents of a file but keep its attributes. Rather than forcing the user to delete a file and recreate it, thos function allows all attributes to remain unchanged-except for file length-but lets the file be reset to length zero and its file space released.

Ques5. What are different schemes for giving the structure of directory?

Ans :- The different schemes for giving the structure of directory-

Single level directory

Two-Level directory

Tree-Structured directory

Acyclic-Graph directory

General Graph directory

Single Level Directory:- This is for all users. This is the simple directory structure. All files contained in the same directory, which is easy to support and understand.

Naming problem

Grouping problem

Two Level Directory:- In two level directory structure, each user has its own user file directory. The UFDs have similar structures, but each lists only the files of a single user. When a user job starts or a user logs in, the system's master file directory is searched. The MFD is indexed by user name or account number, and each entry points to the UFD for that user.

Path name

Can have the same file name for different user

Efficient searching

No grouping capability

Tree-Structured Directory:- A directory contains a set of files or directories. A directory is simply another file, but it is treated in a special way. All directories have the same internal format. One bit in each directory entry defines the entry as file(0) or as a subdirectory(1). Special system calls are used to create and delete directories.

Efficient searching

Grouping Capability

Current directory (working directory)

cd /spell/mail/prog

type list

Absolute or relative path name

Creating a new file is done in current directory

Delete a file

rm <file-name>

Creating a new subdirectory is done in current directory

mkdir <dir-name>

Example: if in current directory /mail

mkdir count

Acyclic-Graph Directories:- A tree structure prohibits the sharing of files or directories. An acyclic graph - that is, a graph with no cycles- allows directories to share subdirectories and files. The same file or subdirectory may be in two different directories. The acyclic graph is a natural generalization of the tree-structured directory scheme.

Two different names (aliasing)

If dict deletes list Þ dangling pointer

Solutions:

Backpointers, so we can delete all pointers

Variable size records a problem

Backpointers using a daisy chain organization

Entry-hold-count solution

New directory entry type

Link - another name (pointer) to an existing file

Resolve the link - follow pointer to locate the file

General -Graph Directory:-

How do we guarantee no cycles?

Allow only links to file not subdirectories

Garbage collection

Every time a new link is added use a cycle detection

algorithm to determine whether it is OK

Ques6. Give different techniques and interfaces which allow i/o devices to communicate in standard way.

Ans:

Memory-mapped I/O (MMIO) and port I/O (also called port-mapped I/O (PMIO) or isolated I/O) are two complementary methods of performing input/output between the CPU and peripheral devices in a computer. Another method, not discussed in this article, is using dedicated I/O processors - commonly known as channels on mainframe computers - that execute their own instructions.

Memory-mapped I/O (not to be confused with memory-mapped file I/O) uses the same address bus to address both memory and I/O devices, and the CPU instructions used to access the memory are also used for accessing devices. In order to accommodate the I/O devices, areas of the CPU's addressable space must be reserved for I/O. The reservation might be temporary - the Commodore 64 could bank switch between its I/O devices and regular memory - or permanent. Each I/O device monitors the CPU's address bus and responds to any of the CPU's access of device-assigned address space, connecting the data bus to a desirable device's hardware register.

Port-mapped I/O uses a special class of CPU instructions specifically for performing I/O. This is generally found on Intel microprocessors, specifically the IN and OUT instructions which can read and write one to four bytes (outb, outw, outl) to an I/O device. I/O devices have a separate address space from general memory, either accomplished by an extra "I/O" pin on the CPU's physical interface, or an entire bus dedicated to I/O. Because the address space for I/O is isolated from that for main memory, this is sometimes referred to as isolated I/O.

A device's direct memory access (DMA) is not affected by those CPU-to-device communication methods; especially it is not affected by memory mapping. This is because by definition, DMA is a memory-to-device communication method that bypasses the CPU.

Hardware interrupt is yet another communication method between CPU and peripheral devices. However, it is always treated separately for a number of reasons. It is device-initiated, as opposed to the methods mentioned above, which are CPU-initiated. It is also unidirectional, as information flows only from device to CPU. Lastly, each interrupt line carries only one bit of information with a fixed meaning, namely "an event that requires attention has occurred in a device on this interrupt line".

Writing Services

Essay Writing
Service

Find out how the very best essay writing service can help you accomplish more and achieve higher marks today.

Assignment Writing Service

From complicated assignments to tricky tasks, our experts can tackle virtually any question thrown at them.

Dissertation Writing Service

A dissertation (also known as a thesis or research project) is probably the most important piece of work for any student! From full dissertations to individual chapters, we’re on hand to support you.

Coursework Writing Service

Our expert qualified writers can help you get your coursework right first time, every time.

Dissertation Proposal Service

The first step to completing a dissertation is to create a proposal that talks about what you wish to do. Our experts can design suitable methodologies - perfect to help you get started with a dissertation.

Report Writing
Service

Reports for any audience. Perfectly structured, professionally written, and tailored to suit your exact requirements.

Essay Skeleton Answer Service

If you’re just looking for some help to get started on an essay, our outline service provides you with a perfect essay plan.

Marking & Proofreading Service

Not sure if your work is hitting the mark? Struggling to get feedback from your lecturer? Our premium marking service was created just for you - get the feedback you deserve now.

Exam Revision
Service

Exams can be one of the most stressful experiences you’ll ever have! Revision is key, and we’re here to help. With custom created revision notes and exam answers, you’ll never feel underprepared again.