Von Neumann Architecture
Concept of Von Neumann Architecture
The Von Neumann architecture, also known as the Princeton architecture, defines a computer design where program instructions and data share the same memory space. This model was proposed by mathematician John von Neumann, who outlined three fundamental principles for computer construction: binary logic, stored-program concept, and a system composed of five components—arithmetic unit, control unit, memory, input devices, and output devices.
Modern computers like desktops, laptops, and servers largely follow this architectural framework.
- Input Devices: Keyboard, microphone, camera, disk, network card, tablet, etc.
- Output Devices: Monitor, speaker, printer, disk, network card, graphics card, etc.
- Central Processing Unit (CPU): Arithmetic unit + Control unit + Other components (registers).
- Memory: Main storage.
In this architecture, all devices interact through memory. CPUs can only read from and write to memory, not directly to peripherals. Data transfer between peripherals and the CPU occurs via memory.
Significance of Memory
Why does the Von Neumann architecture require memory?
Memory serves as temporary storage for data being processed by the CPU and facilitates communication between external storage and the CPU. It's essential because:
- Memory speed is much faster than peripheral devices (nanoseconds vs microseconds vs milliseconds)
- Memory acts as a bridge between fast processors and slower peripherals
- It enables efficient data handling without direct CPU-peripheral interaction
Memory allows for cost-effective performance enhancement. Programs must be loaded into memory before execution because CPUs operate exclusively on memory contents.
Arithmetic and Control Units
The arithmetic unit handles computational tasks including arithmetic and logical operations. The control unit manages data flow and coordinates hardware actions. Although peripherals don't directly communicate with CPUs, they interact through memory, with the control unit managing these interactions.
Operating Systems
An operating system (OS) is a collection of software programs that manage computer hardware and software resources, providing services for user interaction. OS functions as an interface between users and hardware.
Management Principles
Management involves organizing data about objects rather than direct interaction with them. In computing terms, this means describing entities using structures and organizing them efficiently.
For example, a student can be described using a structure containing attributes like name, ID, GPA, etc., which can then be managed through data structures like linked lists.
Resource Management in Operating Systems
OS manages four primary resources:
- Process management
- File management
- Memory management
- Device driver management
These are organized through structured representations and linked lists for efficient access. For instence, process information is stored in task_struct in Linux, which contains process identifiers, state, priority, registers, I/O information, accounting data, and more.
System Calls
System calls provide controlled interfaces between user applications and the kernel. They ensure security and stability by abstracting low-level hardware details. Common system calls include:
getpid()- retrieves current process IDgetppid()- retrieves parent process IDfork()- creates new processes
Process Fundamentals
A process represents a running program in memory. When an executable file is loaded into memory, it becomes a process.
Process Structure
Each process has a corresponding kernel data structure called task_struct. This structure holds essential process information:
- Process identifier (PID)
- Process state
- Priority level
- Program counter
- Memory pointers
- Context data
- I/O status
- Accounting information
The OS manages multiple processes by organizing their task_struct entries in linked lists.
Process Operations
Viewing Processes
Use ps ajx | grep process_name to display specific processes. Alternatively, use ls /proc to view running processes directly.
Terminating Processes
- Foreground processes: Use Ctrl+C
- Background processes: Use
kill -9 <PID>
Process Identification
getpid()returns the current process IDgetppid()returns the parent process ID
Process IDs channge when processes terminate and restart since each process requires a unique identifier.
Creating Child Processes
The fork() system call creates a child process. It returns:
- Child's PID to the parent proces
- Zero to the child process
- Negative value on error
After fork(), both parent and child execute the subsequent code, allowing different behaviors based on return values.
The fork() implementation creates two separate task_struct entries sharing code but maintaining independent data spaces. This dual return mechanism ensures proper process creation and management within the operating system.