Memory Management in OS: Bare Machine, Resident Monitor & Multiprogramming

Operating System · Chapter 20

Memory Management in OS: Bare Machine, Resident Monitor & Multiprogramming

A computer cannot execute a program directly from nowhere. The program and the data it needs must be available in main memory while the CPU is working on them. The operating system therefore needs rules for deciding which program stays in memory, where it stays, how much memory it gets, and how one program is protected from another. These tasks are part of Memory Management in OS.

Memory management did not become advanced in one day. Early computers used a simple Bare Machine model. Later, a small control program called the Resident Monitor stayed in memory. After that, Multiprogramming allowed several programs to remain in memory together so that the CPU did not have to remain idle whenever one job waited for input/output.

Quick Answer: Memory Management in Operating System controls how main memory is allocated, protected, shared and reused by programs. In a Bare Machine system, one program directly uses the machine with almost no operating-system memory control. In a Resident Monitor system, a permanent monitor occupies part of memory and manages jobs one after another. In Multiprogramming, several programs stay in memory at the same time, so the CPU can switch to another program when one program is waiting. This creates new requirements such as allocation, relocation and protection.
EVOLUTION OF MAIN MEMORY MANAGEMENT
1 Bare Machine One program controls the machine directly.
2 Resident Monitor A small system program always remains in memory.
3 Multiprogramming Several jobs stay in memory together.

What Is Memory Management in Operating System?

Memory Management in OS: Bare Machine, Resident Monitor & Multiprogramming

Memory Management in OS is the operating-system function that controls the use of main memory.

It decides how memory is given to programs and how that memory is taken back after a program finishes.

Simple Definition:
Memory management is the process of keeping track of main memory, allocating memory to programs, protecting memory areas and freeing memory when it is no longer required.

Why Does an Operating System Need Memory Management?

Track Memory Know which memory locations are free and which are being used.
Allocate Give suitable memory to a program that needs it.
Protect Stop one process from damaging another process or the operating system.
Relocate Allow programs to run even when they are loaded at different memory locations.
Share Allow controlled sharing where it is useful and safe.
Reuse Return memory to the free pool after a program finishes.

What Is Main Memory?

Main memory, usually RAM, stores instructions and data that are actively needed by running programs.

The CPU can work much faster with data in main memory than with data stored permanently on secondary storage.

SIMPLE MAIN MEMORY VIEW
Operating System Area
User Program Area
Free Memory

The exact memory layout depends on the operating system and memory-management method, but the basic question remains the same: who owns each part of memory?

Main Functions of Memory Management in OS

1 Keeping Track of Memory The operating system records which memory areas are free and which are occupied.
2 Memory Allocation A process receives enough memory for its code, data and execution requirements.
3 Memory Deallocation Memory is returned after a process finishes or releases it.
4 Protection A process should not freely overwrite another process's memory.
5 Address Translation / Relocation Programs need a way to work even when they are placed at different physical locations.
6 Efficient Use Memory should not remain unnecessarily unused while programs are waiting to run.

Bare Machine in Operating System

Stage 1 · Bare Machine Very Early Model

In a Bare Machine system, there is little or no operating-system software between the user program and the hardware.

The programmer or program directly controls much of the machine.

One Program Usually one program is loaded and executed at a time.
Direct Hardware Use The program works very closely with the physical machine.
No Strong Memory Protection There may be little protection against incorrect memory access.
Manual Control Loading and operating the machine requires more human or program-level control.
Bare Machine Memory
One User Program

How Bare Machine Memory Management Works

In the simplest form, the whole available memory can be used by one program.

The program is loaded into memory and then the CPU begins executing it.

When that program finishes, another program may be loaded.

Load Program A Put Program A into memory.
Execute CPU runs Program A.
Finish Program leaves and next program can be loaded.

Advantages and Problems of Bare Machine Systems

Advantages

  • very simple memory model
  • little operating-system overhead
  • program can directly control hardware

Major Problems

  • poor convenience
  • little or no automatic job management
  • weak protection
  • CPU may remain idle during manual operations
  • one program generally controls memory at a time
  • poor support for sharing the computer efficiently

Why Was the Bare Machine Model Not Enough?

Problem

Every job required direct control and repeated loading operations.

Human setup time and program transitions could waste expensive CPU time.

Next Idea

Keep a small control program permanently in memory.

Let that program automatically manage the execution of user jobs.

This small control program became known as a Resident Monitor.

Resident Monitor in Operating System

Stage 2 · Resident Monitor Early Batch System

A Resident Monitor is a small system program that remains permanently in main memory while user jobs are executed.

The monitor controls job sequencing and basic system operations.

Simple Definition:
Resident Monitor is an early operating-system program that stays in memory and automatically controls the loading and execution of user jobs.

Memory Layout in a Resident Monitor System

Resident Part The monitor always occupies one fixed part of memory.
User Area The rest of memory is used for the current user job.
Sequential Execution One user job is normally active in the user area at a time.
Automatic Job Control The monitor loads the next job after the current job finishes.
Resident Monitor Memory Layout
Resident Monitor
Current User Job

How Resident Monitor Works

Job Arrives Monitor identifies the next job.
Load Job Job is placed in the user memory area.
Run & Return Job executes and control returns to the monitor.

After one job finishes, the monitor can automatically prepare the next job.

This reduces the amount of manual intervention required between jobs.

Why Does the Resident Monitor Need Memory Protection?

The resident monitor stays in memory while user code is running.

Therefore, user code should not be allowed to overwrite the monitor area.

Protected Memory Boundary
Resident Monitor
PROTECTION BOUNDARY
User Job Area

Early systems could use hardware protection mechanisms such as a boundary or protection register to prevent the user program from writing into the monitor's protected area.

Limitations of Resident Monitor

Improvement Over Bare Machine

  • automatic job sequencing
  • less manual setup between jobs
  • system code remains available in memory
  • better control over hardware operations

Remaining Problems

  • typically one user job runs at a time
  • CPU can still become idle during slow I/O
  • large parts of memory may remain unused
  • memory utilization is still limited

The Big Problem: CPU Waiting for I/O

Suppose the current job sends a request to a slow input/output device.

The job cannot continue until that I/O operation finishes.

If no other job is available in memory, the CPU may simply wait.

SINGLE JOB SYSTEM · CPU UTILIZATION
P1 CPU
P1 CPU
I/O Wait
CPU Idle
CPU Idle
P1 CPU
P1 CPU
P1 CPU

This wasted CPU time motivated the next big idea: keep more than one program in memory.

Multiprogramming in Operating System

Stage 3 · Multiprogramming Multiple Jobs in Memory

Multiprogramming means keeping multiple programs or jobs in main memory at the same time.

When the currently running program has to wait for I/O, the operating system can give the CPU to another ready program.

Simple Definition:
Multiprogramming is an operating-system technique in which several jobs are kept in memory together so the CPU can switch to another job when one job is waiting.

Memory Layout in Multiprogramming

Now main memory no longer contains only one user job.

Several jobs can occupy different memory areas at the same time.

MULTIPROGRAMMING MEMORY FLOOR PLAN
Operating System
Process P1
Process P2
Process P3

How Multiprogramming Improves CPU Utilization

Suppose P1 begins an I/O operation.

Instead of leaving the CPU idle, the operating system can run P2.

When P2 later waits, P3 may run.

MULTIPROGRAMMED SYSTEM · CPU STAYS BUSY MORE OFTEN
P1
P1
P2
P2
P3
P1
P2
P3
Main idea: Multiprogramming does not make one CPU execute multiple instructions at the exact same moment. It keeps several programs available so the CPU can switch between them when one program cannot continue.

Memory Management Requirements Created by Multiprogramming

Multiprogramming improves CPU utilization, but it makes memory management much more difficult.

Memory Allocation The operating system must decide how much memory each process receives.
Memory Protection P1 must not overwrite P2 or the operating system.
Relocation A program may be loaded at different physical memory addresses.
Free-Space Tracking The operating system must know where unused memory exists.
Process Selection If memory is limited, the OS must decide which jobs should remain in memory.
Controlled Sharing Some memory may need to be shared safely between processes.

Why Is Relocation Needed in Multiprogramming?

In a bare machine, a program may be written or loaded with the assumption that it begins at a fixed memory location.

In multiprogramming, that location may already be occupied by another process.

Program's View

Program works with its own logical addresses.

Example: address 0, 1, 2, 3...

→

Physical Memory

The program may actually be loaded starting from a different physical location.

Example: address 5000 onward.

Therefore, some mechanism is needed to translate or relocate program addresses.

Later memory-management techniques such as base/limit registers, paging and segmentation solve this problem in more advanced ways.

Why Is Memory Protection Important in Multiprogramming?

Several processes are now present in memory at the same time.

Without protection, one incorrect program could overwrite:

Operating System Memory Damaging OS code could crash the complete system.
Another Process P1 should not modify P2's private memory.
Critical Data Unauthorized access could produce incorrect results.

The operating system therefore needs hardware-assisted memory protection.

Simple Protection Idea: Base and Limit

One basic memory-protection concept is to use a base register and a limit register.

Base Register Stores the starting physical address of the process memory area.
Limit Register Defines the allowed size or range of addresses for the process.
Protection Check An address outside the allowed range can cause a protection fault.
This chapter introduces the need for relocation and protection. Detailed logical/physical address translation and advanced allocation techniques should be studied in the next memory-management lessons.

How Can Several Programs Fit Into Memory?

One early approach is to divide available memory into areas or partitions.

Different processes can be loaded into different partitions.

SIMPLE PARTITIONED MEMORY IDEA
Operating System
Partition 1 · P1
Partition 2 · P2
Partition 3 · P3

This leads to important later topics such as:

  • fixed partitioning,
  • variable partitioning,
  • internal fragmentation,
  • external fragmentation,
  • compaction,
  • paging,
  • and segmentation.

Degree of Multiprogramming

The degree of multiprogramming means how many processes are present in main memory and available for execution at a time.

Easy Example:
If P1, P2, P3 and P4 are all loaded into memory, the degree of multiprogramming is 4.

A higher degree can give the CPU more work to choose from, but loading too many processes can also create memory pressure.

Multiprogramming vs Multitasking

Point Multiprogramming Multitasking
Main Goal Keep CPU busy by having multiple jobs available Provide responsive sharing of CPU among active tasks
Typical Switch Reason One job may wait for I/O Scheduler may switch frequently using time sharing
User View Historically batch-oriented Interactive multiple applications
Memory Requirement Several programs may be resident in memory Several active tasks also require managed memory

Bare Machine vs Resident Monitor vs Multiprogramming

Point Bare Machine Resident Monitor Multiprogramming
OS Presence Very little or none Small monitor remains in memory Operating system manages multiple resident jobs
User Jobs in Memory Usually one Usually one active user job Several jobs
Job Switching Mostly manual or direct Monitor automatically starts next job OS can switch between resident jobs
CPU Utilization Poor Better than bare machine Much better when jobs have I/O waits
Memory Protection Need Low in simple one-job model Monitor must be protected from user job OS and all processes must be protected from each other
Memory Complexity Very low Low Much higher
Important New Problem Manual management CPU idle during I/O Allocation, relocation, protection and fragmentation

Why Did Memory Management Evolve?

Bare Machine Problem

The machine required too much direct control and manual job handling.

Resident Monitor Solution

Keep system control software permanently available in memory.

Resident Monitor Problem

CPU could still sit idle when the only user job waited for I/O.

Multiprogramming Solution

Keep multiple jobs in memory so another job can use the CPU.

Important Memory Management Problems Introduced by Multiprogramming

Where Should a Process Be Loaded? Free memory may exist in several different areas.
How Much Memory Should It Receive? Different processes require different memory sizes.
How Do We Protect Processes? One process must not access another process's private memory.
How Do Addresses Still Work? A program may not always begin at the same physical location.
What Happens When Memory Gets Fragmented? Free memory can become divided into inconvenient small pieces.
What If There Is Not Enough RAM? Some programs or memory contents may need to move between RAM and secondary storage.

Logical Address and Physical Address: A Small Preview

As memory management becomes more advanced, it becomes useful to separate the address used by the program from the actual RAM location.

Logical Address Address generated or used from the program's point of view.
Physical Address Actual location in main memory.
Address Translation Hardware and OS mechanisms connect the logical view to physical memory.

This concept becomes extremely important in paging and virtual memory.

Simple Example: Why Multiprogramming Helps

Suppose three programs are available:

P1, P2 and P3.

P1 starts using the CPU. After some time, P1 asks the disk to read a file.

Disk I/O is slow compared with the CPU.

In a one-job system, the CPU may have to wait.

In a multiprogrammed system, the OS can run P2 while P1 waits.

Later, if P2 also waits for I/O, P3 can run.

This is the main benefit: while one job waits, another job can use the CPU.

Important Terms From This Chapter

Memory Management OS control over memory allocation, protection and reuse.
Bare Machine Computer used with little or no resident OS control.
Resident Monitor Small system program that remains permanently in memory.
Multiprogramming Several jobs kept in memory together.
Relocation Ability to run a program when loaded at different memory addresses.
Protection Preventing illegal access to OS or another process's memory.

Common Mistakes Students Make

×
Thinking memory management only means giving RAM.
It also includes tracking, protection, relocation, sharing and deallocation.
×
Thinking Bare Machine means the computer has no memory.
It means the machine operates with little or no resident operating-system control.
×
Thinking Resident Monitor uses all memory.
The monitor occupies one part while the user job uses another part.
×
Thinking Resident Monitor and multiprogramming are identical.
Resident-monitor systems can still execute user jobs mainly one at a time, while multiprogramming keeps several jobs ready in memory.
×
Thinking multiprogramming means multiple CPUs.
One CPU can still support multiprogramming by switching among several resident jobs.
×
Thinking multiprogramming means true parallel execution.
On one CPU, jobs execute one at a time but the CPU switches when needed.
×
Ignoring memory protection.
Multiple resident programs make protection essential.
×
Ignoring relocation.
A program may be loaded at different physical locations in a multiprogrammed system.

Memory Management Evolution in Simple Steps

1 Bare Machine One program directly uses the machine.
2 Resident Monitor A permanent system program stays in memory.
3 Automatic Job Control Monitor loads and runs jobs one after another.
4 I/O Waiting Problem CPU can still become idle while one job waits.
5 Multiprogramming Several jobs stay in memory together.
6 Advanced Memory Management Needed Allocation, relocation, protection and fragmentation become important.

Memory Management in OS Exam Preparation

OPERATING SYSTEM · CHAPTER 20 · EXAM MODE

For a 2-Mark Question

Answer: Memory management is the operating-system function that keeps track of main memory, allocates memory to programs, protects memory areas and frees memory when it is no longer required.

Bare Machine Short Answer

A Bare Machine system has little or no resident operating-system control. One program generally uses the machine and memory directly at a time.

Resident Monitor Short Answer

Resident Monitor is an early operating-system program that remains permanently in memory and controls the loading and execution of user jobs.

Multiprogramming Short Answer

Multiprogramming keeps several jobs in main memory so that the CPU can execute another job when the current job is waiting for I/O.

For a 5-Mark Question

  1. define memory management
  2. explain Bare Machine
  3. explain Resident Monitor
  4. explain Multiprogramming
  5. write why multiprogramming improves CPU utilization

For a 10-Mark Question

  1. meaning of Memory Management in OS
  2. functions of memory management
  3. Bare Machine memory model
  4. limitations of Bare Machine
  5. Resident Monitor
  6. Resident Monitor memory layout
  7. need for protection
  8. limitations of single-job batch systems
  9. Multiprogramming
  10. CPU utilization improvement
  11. memory allocation
  12. relocation
  13. protection
  14. comparison of all three stages

Memory Management Practice Questions

Q1. What is Memory Management in Operating System?
Q2. What are the main functions of memory management?
Q3. What is a Bare Machine system?
Q4. What are the limitations of Bare Machine?
Q5. What is Resident Monitor?
Q6. Draw and explain Resident Monitor memory layout.
Q7. Why must Resident Monitor be protected?
Q8. What problem remains in a single-job Resident Monitor system?
Q9. What is Multiprogramming in OS?
Q10. How does multiprogramming improve CPU utilization?
Q11. Why does multiprogramming need memory protection?
Q12. Why is relocation required?
Q13. What is degree of multiprogramming?
Q14. Differentiate Bare Machine and Resident Monitor.
Q15. Differentiate Resident Monitor and Multiprogramming.
Q16. Differentiate Multiprogramming and Multitasking.
Q17. What is memory allocation?
Q18. What is memory protection?
Q19. What is logical address?
Q20. Why did memory management become more complex with multiprogramming?

Memory Management Quick Revision

Memory Management: controls allocation, protection and reuse of main memory.
Bare Machine: little or no resident OS control.
Bare Machine Jobs: usually one program in memory at a time.
Resident Monitor: small system program permanently stays in memory.
User Area: memory used by the current user job.
Monitor Protection: user job must not overwrite system memory.
Multiprogramming: multiple jobs remain in memory.
Main Benefit: CPU can run another job during I/O wait.
Allocation: deciding where processes get memory.
Relocation: program can work at different physical locations.
Protection: processes cannot freely overwrite each other.
Degree of Multiprogramming: number of resident processes.
Logical Address: address seen by the program.
Physical Address: actual RAM location.
Evolution: Bare Machine → Resident Monitor → Multiprogramming.
Next Memory Topics: partitioning, fragmentation, paging and segmentation.

Frequently Asked Questions About Memory Management in OS

What is Memory Management in Operating System?

Memory Management in Operating System is the function that keeps track of main memory, allocates memory to programs, protects memory areas and frees memory after programs no longer need it.

What is a Bare Machine in OS?

A Bare Machine is an early or minimal computing environment in which little or no resident operating-system software controls the machine. A program works very directly with hardware and memory.

How is memory used in a Bare Machine system?

In the simplest Bare Machine model, one user program can occupy the available memory and execute until it finishes.

What is Resident Monitor in Operating System?

Resident Monitor is an early system program that remains permanently in main memory and controls the loading and execution of user jobs.

Why is it called Resident Monitor?

It is called resident because the monitor remains resident, or permanently present, in main memory while user jobs are executed.

What is the memory layout of Resident Monitor?

One part of memory is reserved for the Resident Monitor, while the remaining user area is used for the current user job.

What is Multiprogramming in Operating System?

Multiprogramming is a technique in which several programs are kept in main memory together so the CPU can switch to another program when the current program is waiting.

Why does multiprogramming improve CPU utilization?

When one job waits for input/output, the CPU can execute another ready job instead of remaining idle.

Does multiprogramming require multiple CPUs?

No. Multiprogramming can work on a single CPU because the operating system switches the CPU among multiple programs that are already in memory.

What is degree of multiprogramming?

Degree of multiprogramming is the number of processes or jobs currently present in main memory and available for execution.

Why is memory protection needed in multiprogramming?

Memory protection is needed because several processes share main memory. One process should not overwrite the operating system or another process's memory.

Why is relocation needed in memory management?

Relocation is needed because a process may be loaded at different physical memory locations depending on which parts of memory are available.

What is the difference between Bare Machine and Resident Monitor?

A Bare Machine has little or no resident operating-system control, while a Resident Monitor system keeps a small control program permanently in memory to manage jobs automatically.

What is the difference between Resident Monitor and Multiprogramming?

A Resident Monitor mainly manages user jobs one after another, while multiprogramming keeps multiple jobs in memory together so the CPU can switch among them when one job waits.

What is the difference between multiprogramming and multitasking?

Multiprogramming mainly aims to keep the CPU busy by maintaining multiple jobs in memory, while multitasking emphasizes responsive time sharing among active tasks.

What memory-management problems appear with multiprogramming?

Important problems include memory allocation, protection, relocation, free-space tracking, fragmentation and deciding which processes should remain in memory.

Conclusion

Memory Management in OS became more important as computers moved from simple one-program systems to systems that could keep many programs ready at the same time.

In a Bare Machine, one program directly controlled the machine with very little operating-system support.

The Resident Monitor improved this model by keeping a small control program permanently in memory. It could automatically load and execute jobs one after another.

But a single job could still make the CPU wait during slow I/O. Multiprogramming solved this problem by keeping several jobs in memory so another job could use the CPU while one job waited.

This improvement created new memory-management requirements: allocation, relocation, protection, free-space management and controlled sharing.

The easiest way to remember this chapter is: Bare Machine = one program, Resident Monitor = one permanent controller, Multiprogramming = many programs in memory.

Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.
Join Telegram Exam updates and free resources