In: Computer Science
What does the Operating System do with registers such as the PC, IR, PSW, and MAR?
It uses the PC to locate the instruction for the IR and address for the MAR, then puts the metadata results of execute into the PSW
During a swapping it moves them between memory and the hard drive
During a context switch it moves them between the PCB/TCB and microprocessor
Nothing, these are hardware components
Role of different registers
PC:
The Program Counter is one of the most important registers in the CPU. A program is a series of instructions stored in the memory. These instructions tell the CPU exactly how to get the desired result. It is important that these instructions must be executed in a proper order to get the correct result. This sequence of instruction execution is monitored by the program counter. It keeps track of which instruction is being executed and what the next instruction will be.
IR:
The instruction register (IR) is used to hold the instruction that is currently being executed. The contents of IR are available to the control unit, which generate the timing signals that control the various processing elements involved in executing the instruction.
MAR:
MAR are used to handle the data transfer between the main memory and the processor. The MAR holds the address of the main memory to or from which data is to be transferred.
All processor designs also include a register or set of registers, often known as the program status word (PSW), which contains status information. The PSW typically contains condition codes plus other status information. Common fields and flags include the following:
• Sign: Contains the sign bit of the last arithmetic operation.
• Zero: Set when the result of an arithmetic operation is zero.
• Carry: Set if an operation resulted in a carry (addition) into or borrow (subtraction) out of a high-order bit. Used for multi-word arithmetic operations. • Equal: Set if a logical compare result is equality.
• Overflow: Used to indicate arithmetic overflow. • Interrupt Enable/Disable: Used to disable or enable interrupts. When interrupts are disabled, the processor ignores them. This is often desirable when the operating system is in the midst of dealing with another interrupt.
• Supervisor: Indicates whether the processor is executing in supervisor or user mode. Certain privileged instructions can be executed only in supervisor mode, and certain areas of memory can be accessed only in supervisor mode
-------------------------------------------------------
By understanding about these registers we can conclude that first option is the most suitable answer.