Summary: This article explains to you how does hardware and software work together.

Nowadays, it’s almost impossible to find a person who doesn’t own a computer. Computers have become a part of our lives.

For me, I can’t imagine my life without a computer. Even though almost every person in the world has a PCs and Laptops, only a few of them know the inner workings of a computer.

In this article, I will explain to you guys how does hardware and software work together right after you press the power button on your PC/Laptop. So let’s get started.

For a Computer to start functioning when its power on or reboot, it needs to have an initial program/ bootstrap program.

A Bootstrap is a program that initializes the operating system during startup. This program is stored in ROM (Read Only Memory) or EEPROM (Electrically Erasable and Programmable Read Only Memory).

This bootstrap program locates the OS kernel and loads it into the memory. When the kernel is loaded and executed, it can start providing services to the system and its users.

When this phase is completed the system is fully booted. The system waits for some events to occur.

The Bootstrap Process
The Bootstrap Process

The occurrence of an event is signaled by an interrupt from either software or hardware. Hardware may trigger an interrupt any time by sending a signal to the CPU. Software triggers an interrupt by executing a special operation called System Call / Monitor Call.

When CPU interrupted;

Handling Interrupts
Handling Interrupts

These interrupts have the highest priority than other signals. There are many types of interrupts. But as mentioned above Hardware interrupts and Software interrupts are the main types of interrupts.

Interaction Between Hardware And Software In A Computer System

Hardware Interrupts

If the signal for the processor is from an external device or hardware its called a Hardware Interrupt. For example, when you click your mouse to do some action it will generate a signal to the processor. This is called a Hardware Interrupt. There are two types in Hardware Interrupts.

  1. Maskable Interrupt
  2. Non-Maskable Interrupt

Maskable interruption can be delayed when a highest priority interrupt has occurred to the processor. But Non-Maskable Interrupt cannot be delayed and should process by the processor immediately.

Software Interrupts

Interrupts generated by executing an instruction or an exceptional condition in the processor itself are called Software Interrupts. There are two types of Software Interrupts.

  1. Normal Interrupts
  2. Exceptions – These are accidental interrupts occur while executing a program.

Each interrupt has its own interrupt handler. This interrupt handler is also called a Interrupt service routine (ISR). There are two types of interrupt handlers.

  1. First Level Interrupt Handler (FLIH)
  2. Second Level Interrupt Handler (SLIH) 

Also Read: How To Unlock Pattern Lock In Android Phone

Storage Structure In Operating System

CPU can load instructions only from memory. General purpose PCs use re-writable memory know as Main memory a.k.a RAM which implemented in a semiconductor technology called DRAM (Dynamic random-access memory)

ROM cannot be changed. Therefore only static programs such as bootstrap are stored inside ROM. EEPROM can be changed but can’t change frequently so it also contains mostly static programs.

All forms of memory provide an array of bytes. Each byte has its own address. Interactions are archived through a sequence of load and store instructions to specific memory addresses. Load Instructions move a byte or word from main memory to internal registers within the CPU while Store instructions move content in a register to the main memory.

Typical Instruction-Execution Cycle which executes with a Von Neumann Architecture.

Typical Instruction-Execution Cycle
Typical Instruction-Execution Cycle

Input Output Management In Operating System

In a general purpose computer CPU consist of multiple device controllers that are connected through a common bus.

Each device controller is in charge of a specific device. A device controller maintains some local buffer and a set of special-purpose registers.

This device controller is responsible for moving data between the peripheral devices that it controls and its local buffer storage.

Operating System has device drivers for each device controller.

Basic Input Output Operations

Typical Input/Output Operation
Typical Input/Output Operation

This kind or Typical Input/Output Operation works fine for a small amount of data but not appropriate for bulk amount of data. For a bulk amount of data DMA (Direct memory access) is used.

In this, the device controller transfer block of data directly from its buffer storage to memory.

Only one interrupt is generated per memory block. While the device controller is performing these operations the CPU is available to accomplish other work.

Also Read: How To Install Burp Suite In Ubuntu

Operating System Structure

Operating System keeps several jobs in memory. Main memory is too small to accomplish all jobs. Therefore the jobs are initially on the disk in the job pool. This pool consists of all processes residing on disk awaiting allocation of main memory.

The set of jobs in memory can be a subset of jobs in the job pool. The OS picks and begins executing one of the jobs in memory.

Eventually, the job may have to wait for some tasks to complete. In non-multi-programmed systems CPU would sit idle until the task completes. But in multi-programmed systems, the OS switch and execute another job. When that job also needs to wait, the CPU switch to another job and so on.

At system boot time, the hardware starts in the kernel mode. The OS is then loaded and starts user applications in user mode. When a trap or an interrupt occur the hardware switches from user mode to kernel mode. When OS gain control of the computer, it is kernel mode. The system always switches to user mode before passing controls to a user program.

Some instructions run only in kernel mode. They are known as privileged instructions.

Transition from user mode to kernel mode
Transition from user mode to kernel mode

This is a simplified and summarized explanation about how does hardware and software work together. Thank you for reading. I hope you enjoyed and learned something new. 

Reference – Operating System Concepts by Avi Silberschatz

Write A Comment