Operating Systems & Administration
[Day 2] 4. Executable File
D
DITISS Admin!4. Executable File.png
Executable File Structure
An executable file contains several key sections, each serving a specific purpose:
-
Executable Header:
- Contains information about the program, such as its name and size.
- Specifies the type of program (e.g., CLI, GUI, library).
- Provides the address of the entry point function.
- Includes information about the remaining sections (start/end).
- Contains a magic number:
- Serves as an identifier for the file format.
- Takes up 2 to 4 bytes of space.
- Examples:
- (Linux): Executable and Linkable Format (ELF)
.out - (Windows): Portable Executable (MZ)
.exe
-
TEXT Section:
- Contains instructions in machine code format.
- Also referred to as the code section.
-
Data Section:
- Contains initialised static and global variables.
- Example:
int num = 10;
-
BSS (Block Started by Symbol) Section:
- Contains uninitialised static and global variables.
- Example:
int num;
-
RO (Read Only) Data Section:
- Contains read-only data, such as string constants.
- Example:
char* ptr = "sunbeam";
-
Symbol Table:
- Stores information about symbols.
- Two types of symbols:
- Variables: Includes name, size, address, section, type, etc.
- Functions: Includes name, address, return type, and the number and type of arguments.
Process Execution
- The CPU cannot directly access the hard disk; it requires data to be loaded into RAM for faster access.
- The loader is responsible for transferring data from the hard disk to RAM while utilising information from the executable header and symbol table.
Memory Structure
-
Stack:
- Stores the Function Activation Record (FAR) and local variables.
-
Heap:
- Stores dynamically allocated space.
-
Process Control Block (PCB):
- Contains information required to control the execution of a process.
- Stores Process ID (PID) and Parent Process ID (PPID).
Process from OS Perspective
From the operating system's perspective, a process consists of all its sections loaded into memory along with the PCB.
- The space where the OS is loaded is known as Kernel Space.
- The space where user applications run is referred to as User Space.
Commands for Process Management
- Whenever a command is executed, it is treated as a program that is first loaded into RAM, with a PCB created for it.
-
Top Command:
- Displays active processes in a top-ordered list.
-
Echo Command:
- : Displays the current shell being used.
echo $SHELL
-
Process Status Commands:
- : Displays the running processes of the current shell.
ps - : Displays all running processes in RAM.
ps -e - : Changes the format of the output to show specific details (PID, PPID, command).
ps -e -o pid,ppid,cmd
-
TTY:
- Stands for Terminal.
Read Next
8/26/2026
[Day 2] 5. Process Life Cycle
!5. Process Life Cycle.png The **5-state process model** is commonly used in operating systems to describe the various states a process can be in d...
8/26/2026
[Day 2] 6. Some more commands
### File Manipulation Commands #### Displaying File Content 1. **Number Lines**: `cat -n <filename>` - Displays the contents of the fi...