Professional Documents
Culture Documents
Memory Protection in Operating System
Memory Protection in Operating System
In the above diagram, when the scheduler selects a process for the execution
process, the dispatcher, on the other hand, is responsible for loading the
relocation and limit registers with the correct values as part of the context switch
as every address generated by the CPU is checked against these 2 registers, and
we may protect the operating system, programs, and the data of the users from
being altered by this running process.
Need of Memory protection:
Memory protection prevents a process from accessing unallocated memory in OS
as it stops the software from seizing control of an excessive amount of memory
and may cause damage that will impact other software which is currently being
used or may create a loss of saved data. These resources of memory protection
also help in detecting malicious or harmful applications, that may after damaged
the processes of the operating system.
Memory protection refers to the mechanism used by the OS to protect one program
from accessing or modifying the memory used by another program. This is
necessary because programs may inadvertently or maliciously access memory that
they should not be able to access, which can cause errors or security
vulnerabilities. The OS typically uses hardware memory management units
(MMUs) to enforce memory protection by assigning each program its own virtual
address space that is mapped to physical memory. The MMU ensures that each
program can only access the memory that it has been authorized to access.
Memory sharing, on the other hand, refers to the ability of multiple programs to
share a common area of memory. This can be useful in many scenarios, such as
when multiple programs need to access the same data or when a program needs to
communicate with another program. In order to facilitate memory sharing, the OS
may provide various mechanisms such as shared memory, pipes, and sockets.
These mechanisms allow programs to communicate and share data with each other
without violating memory protection rules.
The MMU achieves this by dividing the memory into pages or segments and
assigning permissions to each page or segment. Permissions can include read,
write, and execute access, as well as various levels of access restrictions. When a
program attempts to access memory, the MMU checks the permissions associated
with the memory address being accessed, and allows or denies access based on
those permissions.