Yasin Fatullayev
Yasin Fatullayev

Reputation: 169

Operating system-loader

My question is how operating system loads User space application to RAM. I know how Bootloader works when we first turn computer on Bios simply reads 512 kb data till aa55 bootloader signature and loads bootloader to ram. Do regular userspace programms are handled in this way? If yes how? Because bootloader activated by bios and how user space program handled by operating system? More specifacally how execv() load program to RAM and start execution point for user space ? Thanks in advance

Upvotes: 0

Views: 264

Answers (2)

user3344003
user3344003

Reputation: 21637

The procedure varies among operating systems. Some systems have a background command interpreter that exists through the life of a process and within the process itself. When a program is run, the command interpreter stays in the background (in protected from user mode access). When the program completes, the command interpreter comes to the foreground and can run another program in the same process.

In the Eunuchs-world, the command interpreter is just a user-mode program. Whenever it runs a program it kicks off another process.

Both of these types of systems use a loader to configure the process address space for running a program. The executable file is a set of instructions that define how to lay out the address space,

This is significantly different from a bootloader. A bootloader blindly loads a block of stored data into memory. A program loader contains complex instructions for laying out a process address space that include handling shared libraries and doing address fixups.

Upvotes: 1

smilingjames
smilingjames

Reputation: 101

Userspace programs are not handled like the bios, the Kernel will be involved in running a userspace program.

In general: When a program is executed in shell, the shell will invoke system calls to create a new task in a new address space, read in the executable binary, and begin executing it.

To understand the details, you need to understand:

  1. The elf format. Of course there are also other formats which can be used in Linux, elf is just the most common one, and a good starting point. Understanding elf will help you understand how the kernel loads the executable binary into memory precisely.

  2. Linux process management; this will help you to understand how a program starts to run.

  3. Reading the related codes in the kernel. fs/exec.c will be of great help.

Upvotes: 1

Related Questions