Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

You have a multi-user, multi-core computer with multiple processes currently run

ID: 3575553 • Letter: Y

Question

You have a multi-user, multi-core computer with multiple processes currently running. Your process is going to create a new process that creates multiple threads to read some startup information from a disk and do some processing on that data. Your process will write periodic checkpoints to disk. Trace this new process from creation through execution to completion, detailing the operations the OS provides. Be sure to include discussion of scenarios where "generally it works like this, but sometimes X happens and we have to do Y to take care of it."

Include:

Process: Include how the process is created and what synchonization might be needed when kernel (system) structures are updated. If this is the first entry in the structure and structure needs to be allocated, where are how it is allocated? Discuss user mode vs kernel mode and how to switch between them, as well as threads passing data back and forth.

Memory: The system uses demand paging, so include steps the OS might go through to execute an instruction, including reading from memory. Discuss how the kernel allocates and uses its own memory.

Storage: What happens when the process has to read from or write to the disk? What steps does the OS go through to find the file on disk? When the disk controller has read in the data, how does it transfer it to the process?

Explanation / Answer

Process

Can execute any instructions related to central processing unit

It can refer any memory address

This mode is reserved fo ]r important,trusted functions of operating system

In case of a crash entire system will come down

2.User mode:

Code has no direct control over memory or hardware

our normal code executes in user mode

results of crash are not catastrophic due to isolation and generally can be recovered.

switching from user mode to kernel mode

This involves 3 steps or stages

step1:Whenever a user application calls system call APIs like open,reas,write with appropriate parameters, a software interrupt/exception(SWI) is triggered.

Kernel Mode

Code has unlimited access over hardware.

step 2:As a result of this SWI or software interrupt, the control of the code execution jumps from the user application to a predefined location in the Interrupt Vector Table [IVT] provided by the Operating system

step 3:This IVT contains an adress for the SWI exception handler routine.This adress performs all the necessary steps required to switch the user application to kernel mode and start executing kernel instructions on behalf of user process

switching from kernel mode to user mode

step 1:When the kernel has to return to user mode, the trapret code pops all values stored in the kernel stack back to the hardware registers.

step 2:But when iret which is the lastinstruction pops eip from the kernel stack, the next instruction that should get executed is the return address in user mode.This happs only after all the values are popped from the stack.

memory

how kernel allocates its own memory

approach 1:

Buddy memory allocation
kmalloc is a function used by Linux kernel which allocates a permanent memory block . It has to free explicitly

approach 2:
2) Slab Allocation:
Each unit in linux kernel has a fixed size called slabs. so what kernel does is, it allocates different slabs for all such different units like different slabs for a block of memory for PCB, a different slab for inodes.

Storage:

when operating systems has to write on disk,it finds the empty space by allocating space required for file in the disk.The read/write head points and writes the data to that location

while reading  concept of inode comes.An inode is and entry in inode table which keeps information about files like its location on disk.Its makes an entry called inode entry or inode number of that file in inode table which will help to locate that file in future in case we have to refer to that file.

To find a file on disk,OS will refer to inode table to get the inode entry which will give access to file

Can execute any instructions related to central processing unit

It can refer any memory address

This mode is reserved fo ]r important,trusted functions of operating system

In case of a crash entire system will come down

2.User mode:

Code has no direct control over memory or hardware

our normal code executes in user mode

results of crash are not catastrophic due to isolation and generally can be recovered.

switching from user mode to kernel mode

This involves 3 steps or stages

step1:Whenever a user application calls system call APIs like open,reas,write with appropriate parameters, a software interrupt/exception(SWI) is triggered.

  1. Kernel Mode

    Code has unlimited access over hardware.

step 2:As a result of this SWI or software interrupt, the control of the code execution jumps from the user application to a predefined location in the Interrupt Vector Table [IVT] provided by the Operating system

step 3:This IVT contains an adress for the SWI exception handler routine.This adress performs all the necessary steps required to switch the user application to kernel mode and start executing kernel instructions on behalf of user process

switching from kernel mode to user mode

step 1:When the kernel has to return to user mode, the trapret code pops all values stored in the kernel stack back to the hardware registers.

step 2:But when iret which is the lastinstruction pops eip from the kernel stack, the next instruction that should get executed is the return address in user mode.This happs only after all the values are popped from the stack.

memory

how kernel allocates its own memory

approach 1:

Buddy memory allocation
kmalloc is a function used by Linux kernel which allocates a permanent memory block . It has to free explicitly

approach 2:
2) Slab Allocation:
Each unit in linux kernel has a fixed size called slabs. so what kernel does is, it allocates different slabs for all such different units like different slabs for a block of memory for PCB, a different slab for inodes.

Storage:

when operating systems has to write on disk,it finds the empty space by allocating space required for file in the disk.The read/write head points and writes the data to that location

while reading  concept of inode comes.An inode is and entry in inode table which keeps information about files like its location on disk.Its makes an entry called inode entry or inode number of that file in inode table which will help to locate that file in future in case we have to refer to that file.

To find a file on disk,OS will refer to inode table to get the inode entry which will give access to file

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote