Exam 1 CSCE 313 (kebo)

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

Interrupt Handler

An interrupt handler is a program that services an interrupt then resumes the interrupted program.

Process Scheduling Queues

Process Scheduling Queues • Job queue - set of all processes in the system • Ready queue - set of all processes residing in main memory, ready and waiting to execute • Device queues - set of processes waiting for an I/O device Processes migrate among the various queues

Zombie Processes

1. After a fork() the child process executes independently of the parent. 2. If the parent does not to wait for the child to terminate and executes subsequent tasks, then at the termination of the child, the exit status is not captured by the parent. 3. A PCB (Process Control Block) entry remains the process table even afterthe termination of the child. 4. The orphaned child becomes a zombie process. 5. Multiple zombies can result in memory leaks, because the PCBs takememory and are not deallocated.

Zombie Prevention Methods

How to prevent zombie processes? a) Using wait() system call b) Ignoring the 'SIGCHLD' signal c) Using a signal handler

Running another program from a c/c++ program

1. Assuming the other program's name is name. 2. The current program makes a system call execXX("name", arglist). 3. The kernel loads the "name" executable program from the disk into the process. 4. The kernel copies arglist into the process. 5. The kernel calls main(arglist) of the name program.

How a program is executed

1. After compilation, the hello.c program is translated into an executable file that is stored on the computer disk. 2. The command ./hello runs the executable file by loading the program from the disk to the main memory (Direct Memory Access) 3. The processor fetches the program from the main memory, decodes, and executes it. 4. The hello program prints its message to the screen and terminates.

execle()

With execle(), we can pass environment variables to the function, and it will use them:

Multiprocessing with multiple cores

- Multiple CPUs cores on single chip - Share main memory (and some of the caches) - Each can execute a separate process • Kernel schedules processes to cores • Still constantly swapping processes

Exception Control Flow

an exception results in the transfer of the control to the OS in response to some event.

Interrupt Flow

1. Something tells the processor core there is an interrupt 2. Core transfers control to code that needs to be executed 3. Said code "returns" to old program

Memory Management

Operating systems provide a separate page table, and thus a separate virtual address space, for each process.

Files for interprocess communication

Two programs can communicate with one another by using an intermediate medium like a file.

program execution flow

1. Load instruction and data segments of executable file into memory. 2. Create stack and heap. 3. Transfer control to it 4. Provide services to it (network, file connections, IO, etc.)

why file descriptors

Why do we need to open and close sessions when we read from or write to files? Because the system must internally store (cache) a lot of information about the file as we access it. • Where is file stored on which storage device? • Where are we as we sequentially traverse file? • Which parts of the file are cached? and where? • Who else is accessing the file right now? • etc.

fork()

fork() is a system call that creates a new process by duplicating the calling process. The process calling fork() is the parent process. The new process is the child process. pid_t fork(void); What are the return values of fork()? < 0 : fork failure - child process not created = 0 : fork success - value 0 returned to the child process > 0 : fork success - process ID of the child process returned to the parent process.

Creating new processes and programs

fork-exec model (Linux): - fork() creates a copy of the current process - exec*() replaces the current process' code and address space with the code for a different program • Family: execv, execl, execve, execle, execvp, execlp - fork() and execve() are system calls Other system calls for process management: - getpid() - exit() - wait(), waitpid() fork() system call creates new process exec() system call used after a fork() to replace the process' memory space with a new program

Summary of Exception classes

interrupt: cause - signal from i/o device asynch/synch? - asynch return behavior - returns to next instruction Fault: cause - unintentional and maybe unrecoverable error asynch/synch? - sync return behavior - maybe return to current instruction Abort: cause - unintentional and non-recoverable error asynch/sync? - sync return behavior - does not return Traps/System Calls: cause - intentional from within user application asynch/sync? - sync return behavior - return to next instruction

Processes in Linux

output when typing "ps" in shell PID returns the unique process ID TTY returns the terminal type you're logged into TIME returns the total amount of CPU usage CMD returns the name of the command that launched the process.

How to create a pipe

pipe() takes an array of two ints as an argument. What are the return values of pipe()? -1: pipe failure 0: pipe success pipe() fills in the array with two file descriptors.

Operating System (OS)

software that manages computer hardware and software resources. The operating system (OS) interfaces between the application program and the hardware. The OS allows multiple users can run programs The OS supports multitasking: multiple processes can run simultaneously. A process is an abstraction of a running program. A process consists of multiple execution units called threads.

unix Files

unix files have a seuqence of m bytes

Polling

when using polling to deal with an event: • We can repeatedly poll the app/processor/peripherals • When an event occurs, detect it via a poll and take action Polling affects the responsiveness of the application Polling affects the efficiency of the processor • The ldr/str values don't change very much either • So, the processor is mostly wasting CPU cycles (and energy)

unix file types

• Regular files File containing user/app data (binary, text, whatever) • Directory files A file that contains the names and locations of other files • Character special and block special files Terminals (character special) and disks (block special) • FIFO (named pipe) A file type used for inter-process communication • Socket A file type used for network communication between processes

Multiprocessing

• Single processor executes multiple processes concurrently • The CPU runs one process at a time • Address spaces managed by virtual memory system • Execution context (register values, stack, ...) for other processes saved in memory

what happens in exec()

• The exec system call clears out the binary of the current program from the current process and then in the now empty process puts the code of the program named in the exec call and then runs the new program • execvp does not return if it succeeds!

zombie prevention using SIG_CHLD

• The parent process installs a signal handler for the SIGCHLD signal. The signal handler calls wait() system call within it. • When the child terminates, the SIGCHLD is delivered to the parent. • On receipt of SIGCHLD, the corresponding handler is activated, which in turn calls the wait() system call. • The parent collects the exit status almost immediately and the child entry in the process table is cleared.

zombie prevention using SIGCHLD and SIG_IGN

• When a child is terminated, a corresponding SIGCHLD signal is delivered to the parent. • When calling the signal(SIGCHLD,SIG_IGN), the SIGCHLD signal is ignored by the system. • The child process entry is deleted from the process table and no zombie is created.

zombie prevention using wait

• When the parent process calls wait(), after the creation of a child, it will wait for the child to complete and it will reap the exit status of the child. • The parent process is suspended (waits in a waiting queue) until the child is terminated. • During the wait period, the parent process does nothing else.

Limitations of FIFO

• Although FIFOs use standard file I/O functions (e.g., open(), read(), and write()), they are not regular files! • Once data is read from a FIFO, the data is discarded and cannot be read again. • With a regular file, multiple processes can read the same data from the same file. Regular files store data persistently, but FIFOs do not. • FIFOs cannot be used for broadcasting a single message to multiple recipients; only one process can read the data. • FIFOs (like pipes) are not suitable for bi-directional communication; if a process writes into the FIFO then immediately tries to read a response, it may read its own message.

Interrupts caused by external world

• External device • Reset button • Timer expires • Power failure • System error

Compilation System

1. Preprocessor: prepares the hello.c file for compilation by including the library files that the program requires. 2. Compiler: translates the text file hello.i into the assembly language file hello.s. 3. Assembler: translates the assembly language file hello.s into an object file hello.o. 4. Linker: takes the object files generated by the compiler and combines them into one executable object file. 5. Loader: loads the program machine code in main memory.

execve()

We can pass environment variables to execve(). In addition, the arguments need to be inside a NULL-terminated vector.

execl()

execl() receives the location of the executable file as its first argument. The next arguments will be available to the file when it's executed. The last argument must be NULL.

execvp()

execvp() looks for the program in the PATH environment variable.

Limitations of pipes

1. Unix pipes are unidirectional channels from one process to another, and cannot be turned into bidirectional or multicast channels. This limitation makes pipes useless for complex inter-process communication. 2. The pipe system call creates a single "read end" and a single "write end". Bidirectional communication can be simulated using a pair of pipes, but inconsistent buffering between both pipes can lead to a deadlock, especially if we only has control of the program on one end of the pipe. 3. Pipes can only be shared between processes with a common ancestor. 4. This restriction prevents many useful forms of inter-process communication from being layered on top of pipes. 5. Pipes are a form of combination, there is no way for a process to name a pipe that it (or an ancestor) did not directly create via pipe. 6. Pipes cannot be used for clients to connect to long-running services. 7. Processes cannot open additional pipes to other processes that they already have a pipe to.

Context Switch: PCB and hardware states

1. When a process is running, its hardware state (PC, SP, registers, etc.) is in the CPU. The hardware registers contain the current values. 2. When the OS stops running a process, it saves the current values of the registers into the process' PCB. 3. When the OS is ready to start executing a new process, it loads the hardware registers from the values stored in that process' PCB. The process of changing the CPU hardware state from one process to another is called a context switch. This can happen 100 or 1000 or more times a second!

Context Switch

A context switch is an operation that reassigns the CPU from one process or task to another. The execution of the process that is present in the running state is suspended by the kernel and another process that is present in the ready state is executed by the CPU. Control flow passes from one process to another via a context switch Context switch 1) Save current registers in memory 2) Schedule next process for execution 3) Load saved registers and switch address space

Pipe

A pipe is a construct in the Unix OS that allows two processes to communicate. One end of the pipe is the read end; the other is the write end. A pipe is created via a pipe() system call. int pipe(int fd[2]) The function returns a pair of file descriptors* • fd[0] is the read end • fd[1] is the write end Data is received in the order it is sent When any bytes are written to fd[1],the OS makes them available for reading from fd[0].

process

A process is an instance of a program in execution. Every time a user runs a program by typing the name of an executable object file to the shell, the shell creates a new process and then runs the executable object file in the context of this new process. Context consists of: • Process ID • Address space (code, data, heap, stack) • Processor state (registers) • etc. A process provides each program with two key abstractions: Logical control flow: each program seems to have exclusive use of the CPU Private address space: each program seems to have exclusive use of main memory How are these illusions maintained? • Process executions interleaved (multitasking) • Main memory address spaces managed (virtual memory system)

Private Address Space

A program's data can be divided into different parts; therefore they are loaded as groups into memory. Therefore, in very simple terms, the memory looks like the following with several programs loaded:

Traps or System Calls

A trap is a synchronous interrupt intentionally triggered by an exception in a user process to perform an action. Exception conditions like invalid memory access, division by zero, or a breakpoint can trigger a trap in an OS. Examples: • Application program requests more heap memory • Application program requests I/O Traps provide a function-call-like interface between application and OS.

Abort

Aborts are severe and unrecoverable errors. • Examples: parity error, machine check, divide by zero* • Aborts current program and hands control over to the OS • This is the way for the OS to put essential error checking • Also, an excellent way to make OS resilient when applications are failing or crashing

when fork() is called

After a process invokes fork(), control passes to the Kernel, which does the following: 1. Allocates address space and data structures 2. Clones original process into the new process 3. Adds the new process to the set of ready-to-run processes 4. Returns control back to both processes

OS's internal tables

An OS keeps a lot of information in the main memory, much of this info is about: • Resources (e.g., devices, memory state) • Running programs/processes Note that program data is not same as the PCB The PCB is a process's metadata Program's data (variables, allocated memory) and code are kept in the process image (i.e., address space), which is separate and usually bigger in footprint.

Interrupt

An interrupt (exception, trap) is a signal which is sent from a device or from software to the operating system. It causes the CPU to stop its current execution. Here are a few properties of an interrupt: • It can occur between any two instructions • It is transparent to the running program • It is not explicitly requested by the program (typically) • It calls a procedure at an address determined by the type of interrupt, not the program. Two types: 1. Interrupts caused by an instruction. 2. Interrupts caused by the external world.

Background of OS

Applications running in the system are address space abstractions called processes. Processes need to talk to the outside world and they do so via privileged interface (system calls, interrupts). In this module we will focus on the the UNIX I/O interface. • Transfer happens in bytes and using buffers • Every I/O device is treated as a file for uniformity • Basic operations are read and rrite • Checks and Balances are needed to ensure an orderly and efficient transfer. These are done through open and olose, and in the form of session enabled with file descriptors.

How does the OS represent a process in the kernel

At any time, there are many processes in the system, each in its particular state . The OS data structure representing each process is called the Process Control Block (PCB) • The PCB contains all of the info about a process • The PCB is also where the OS keeps all of a process' hardware execution state (PC, SP, registers, etc.) when the process is not running • This state is everything that is needed to restore the hardware to the same configuration it was in when the process was switched out of the hardware

Unix I/o

Basic Unix I/O operations (system calls): - Opening and closing files • open()and close() - Reading and writing a file • read() and write() - Current file position • Kernel maintains a file position (initially 0) for each open file (aka file pointer) • Indicates next (byte) offset into file to read or write • Reading and writing automatically advance the file pointer • lseek()can be used to change file position manually at programmer's wish - Instead of the default which is tied to read and write operations

Process API

Common process operations provisioned in Operating Systems Create: When we type a command into the shell, or double-click on an application icon, the OS is invoked to create a new process to run the program you have indicated. Destroy: Most programs terminate once they complete, but provision for terminating a runaway process is provided Reaping: Best example is a shell program within which another program(s) can be invoked Miscellaneous Control Other operations besides the one above (e.g. suspend, resume, etc.) Status: Check on status of process (e.g. runtime, memory, priority, state, etc.) A process can run more than one program: The currently running program can ask that the OS loads a different program into the same process. The new program inherits some reused process state, such as current directories, file handles, privileges etc. This is done at the system level, with only four syscalls: 1. fork() 2. exec() 3. wait() 4. exit()

pros and cons of unix i/o

Pros - It is the most general and lowest overhead form of I/O • All other I/O packages are implemented using Unix I/O functions on a Unix system - It provides functions for accessing file metadata Cons - Efficient data access requires some form of buffering, which is: • Device dependent (e.g., a whole track of a disk can be read at once) • tricky and error prone - Both of these issues are addressed by standard I/O packages

FIFO (named pipe)

FIFO is a first-in, first-out message-passing IPC in which bytes are sent and received as unstructured streams. It is also known as a named pipe. The named pipe is a POSIX pipe in contrast to anonymous pipes created with the pipe() system call. FIFOs work by attaching a filename to the pipe. Once created, any process (with correct access permissions) can access the FIFO by calling open() on the associated filename. Once the processes have opened the file, they can use the standard read() and write() functions to communicate. In Linux, we can create a FIFO with the commands mknod (using the letter "p" to indicate the FIFO type) or mkfifo. int mkfifo (const char *pathname, mode_t mode); Creates a new file identified by the pathname to use as a FIFO A common use for FIFOs is to create client/server applications on the same machine. e.g.: An anti-virus server running in the background, scanning for infected files. To get a report on potentially bad files, we run a client application that uses a FIFO to connect to the server. • The server and the client application are distinct processes running separate programs (not forked!). • Instead, both processes use the name attached to the FIFO to set up the communication.

Faults

Faults are exceptions detected before the instruction executes, or during execution of the instruction. If detected during the instruction, the fault is reported with the machine restored to a state that permits the instruction to be restarted.

Creating and Terminating processes

From a programmer's perspective, think of a process as being in one of three states: Running. The process is executing on the CPU or waiting to be executed and will eventually be scheduled by the kernel. Stopped. The execution of the process is suspended and will not be scheduled. A process stops as a result of receiving a SIGSTOP, SIGTSTP, SIGTTIN, or SIGTTOU signal, and it remains stopped until it receives a SIGCONT signal, at which point it becomes running again. (A signal is a form of software interrupt) Terminated. The process is stopped permanently. A process becomes terminated for one of three reasons: 1. Receiving a signal whose default action is to terminate the process. 2. Returning from the main routine. 3. Calling the exit function.

choosing i/o functions

General rule: use the highest-level I/O functions you can - Many C programmers are able to do all of their work using the standard I/O functions When to use standard I/O - When working with disk or terminal files When to use raw Unix I/O - Inside signal handlers, because Unix I/O is async-signal-safe - In rare cases when you need absolute highest performance • You do your own buffering depending on the application nature and knowledge about the underlying hardware • On a 24 hard-drive (i.e., 48 TB cap) RAID system, we needed to exploit windows-native I/O to get nearly 3 GB/s read/write speed • Standard I/O would only give us < 1GBps read/write speed

Hardware Protection

Hardware protection is divided in three categories: 1. CPU protection 2. Memory protection 3. I/O protection • Halt and other instructions • Access/modify data on devices • Modify data or code in other programs or monitor itself • Refuse to relinquish processor

what is i/o

I/O is the means to communicate with the 'outside world'. In technical terms, I/O is the process of copying data between the main memory and external devices (disk drives, terminals, networks, etc.). Language run-time systems provide higher-level facilities for performing I/O (e.g. printf/cout, scanf/cin). • On Unix systems, these higher-level I/O functions eventually call System- Level Unix I/O functions provided by the Kernel (e.g., printf() internally calls write()) • The same applies to Windows and other OSs • printf() calls native windows function WriteFile()

pros and cons of standard i/o

Pros: - Portable code - same code works on Windows and Unix - Buffering increases efficiency by decreasing the number of read and write system calls - Less burden on the programmer Cons: - Provides no function for accessing file metadata - Standard I/O is not appropriate for input and output on network sockets • There are poorly documented restrictions on streams that interact badly with restrictions on sockets (CS:APP2e, Sec 10.9)

fork and pipe

It is not useful for one process to use a pipe to talk to itself. Typically, a process creates a pipe just before it forks more child processes. The pipe is then used for communication either between the parent or child processes, or between two sibling processes. In the following program the parent writes a message to the pipe. The child reads from the pipe 1 byte at a time until the pipe is empty.

Schedulers

Long-term scheduler (or job scheduler) - selects which processes should be brought into the ready queue - controls degree of multiprogramming - must select a good process mix of I/O-bound and CPU-bound processes Short-term scheduler (or CPU scheduler) - selects which process should be executed next and allocates CPU - executes at least every 100ms, therefore must be very fast Medium-term scheduler (swapper) - in some OS's - sometimes good to temporarily remove processes from memory (suspended)

Memory protection

Memory protection ensures that one user's process cannot access other's memory. • Protect interrupt vector, interrupt service routines • Determine legal address ranges

multitasking

Multitasking is the concurrent execution of multiple processes over a period. The CPU is running so fast that to any user it appears that the computer is running all the programs simultaneously.

standard i/o functions

The C standard library (libc.so) contains a collection of higher-level standard I/O functions - Documented in Appendix B of K&R. Examples of standard I/O functions: - Opening and closing files (fopen and fclose) - Reading and writing bytes (fread and fwrite) - Reading and writing text lines (fgets and fputs) - Formatted reading and writing (fscanf and fprintf)

Types of System calls

PROCESS CONTROL • load • execute • end, abort • create process • terminate process • get/set process attributes • wait for time, wait event, signal event • allocate, free memory FILE MANAGEMENT • create file, delete file • open, close • read, write, reposition • get/set file attributes DEVICE MANAGEMENT • request device, release device • read, write, reposition • get/set device attributes • logically attach or detach devices INFORMATION MAINTENANCE • get/set time or date • get/set system data • get/set process, file, or device attributes COMMUNICATION • create, delete communication connection • send, receive messages • transfer status information • attach or detach remote devices

pipes for bidirectional communication

Pipes are unidirectional and should not be used to write back. Using a single pipe for bidirectional communication will fail. We can use two pipes for bidirectional communication between parent and child. 1. The parent process uses pcfd to send data to the child process. 2. The child process uses cpfd to send data to the parent process. In both cases, the calls to write() use index 1 and the read() calls use index 0 on the file descriptor array.

Process Control Block(PCB)

Process State - The current state of the process i.e., whether it is ready, running, waiting, or whatever. Process privileges - This is required to allow/disallow access to system resources. Process ID - Unique identification for each of the process in the operating system. Pointer - A pointer to parent process. Program Counter - Program Counter is a pointer to the address of the next instruction to be executed for this process. CPU registers - Various CPU registers where process need to be stored for execution for running state. CPU Scheduling Information - Process priority and other scheduling information which is required to schedule the process. Memory management information - This includes the information of page table, memory limits, Segment table depending on memory used by the operating system. Accounting information - This includes the amount of CPU used for process execution, time limits, execution ID etc. IO status information - This includes a list of I/O devices allocated to the process.

When is a process created?

Processes can be created in two ways • System initialization: one or more processes created when the OS starts up • Execution of a process creation system call: something explicitly asks for a new process System calls can come from • User request to create a new process (system call executed from user shell) • Already running processes • User programs • System daemons

i/o redirection

Question: How does a shell implement I/O redirection? unix> ls > foo.txt Answer: By calling the dup2(oldfd, newfd) function Copies (per-process) descriptor table entry oldfd to entry newfd

Linux Pipe Command

Sending Signals from the Keyboard Unix shells use the abstraction of a job to represent the processes that are created as a result of evaluating a single command line. For example, typing linux> ls | sort This command creates a foreground job consisting of two processes connected by a Unix pipe: one running the ls program, the other running the sort program. (cmd1 | cmd2)

memory regions

Stack This section contains the temporary data such as method/function parameters, return address and local variables. Heap This section is dynamically allocated memory to a process during its run time. Text This section includes the current activity represented by the value of Program Counter and the contents of the processor's registers. Data This section contains the global and static variables.

standard i/o streams

Standard I/O models open files as streams - Abstraction for a file descriptor and a buffer in memory. C programs begin life with three open streams (defined in stdio.h) - stdin (standard input) - stdout (standard output) - stderr (standard error)

lifecyle of processes

Start - This is the initial state when a process is first started/created. Ready- The process is waiting to be assigned to a processor. Ready processes are waiting to have the processor allocated to them by the operating system so that they can run. Process may come into this state after the start state or while running and interrupted by the scheduler to assign CPU to some other process. Running - Once the process has been assigned to a processor by the OS scheduler, the process state is set to running and the processor executes its instructions. Waiting - Process moves into the waiting state if it needs to wait for a resource, such as waiting for user input, or waiting for a file to become available. Terminated or exited - Once the process finishes its execution, or it is terminated by the operating system, it is moved to the terminated state where it waits to be removed from main memory.

Synchronous Exceptions

Synchronous exceptions can be triggered by executing an instruction. From within the user application there are 3 types of synchronous exceptions: 1. Faults 2. Aborts 3. Traps or System Calls

Interrupts caused by instruction

TLB miss • An Illegal/unimplemented instruction • A division by 0 • SVC (supervisor call, e.g.: SVC #3)

dup2()

The dup2() system call creates a copy of a file descriptor. • If the copy is successfully created, then the original and copy file descriptors may be used interchangeably. • They both refer to the same open file description and thus share file offset and file status flags. int dup2 (int oldfd, int newfd); oldfd: old file descriptor newfd: new file descriptor which is used by dup2() to create a copy. Bash uses dup2() with pipes to link commands together. Example: ls | sort • The sort process closes the write end of the pipe and links the read end to become its standard input. • The ls process closes its read end of the pipe and links the write end to its standard output. • Anything that ls writes to its standard output, sort would read from its standard input.

exec functions

The exec functions execute a file. They replace the current process image with a new process image. Even though they are similar, there are differences between them, and each one of them receives different information as arguments. int execl ( const char *path, const char *arg, ... ); int execlp( const char *file, const char *arg, ... ); int execle( const char *path, const char *arg, ..., char *const envp[] ); int execv ( const char *path, char *const argv[] ); int execvp( const char *file, char *const argv[] ); int execve( const char *file, char *const argv[], char *const envp[] ); The first three are of the form execl and accept a variable number of arguments. To use this function, we must load the <stdarg.h> header file. The latter three are of the form execv in which case the arguments are passed using an array of pointers to strings where the last entry is NULL.

creating new processes

The following program creates a new process by invoking the fork() system call. It also uses system calls getpid() to get the calling process's ID and getppid() for the parent's ID. • Because of cloning, everything after the fork() is executed twice, once from the parent and once from the child. "Hello" prints once and "Bye" prints twice. • The terminal (ID=74907) is the parent during the first two prints. • Process IDs are assigned sequentially and recycled after process termination by a garbage collector. After the child is created, the schedule of the parent and children are independent (i.e., the parent or the child might be scheduled first). However, we can synchronize/order the child and the parent.

Process synchronization

The waitpid function makes one process wait for another one. pid_t waitpid (pid_t pid, int *status, int options) The 3 arguments are: • The target process's ID • The address of an integer where termination information (i.e., exit code) can be placed. You can pass NULL if we don't care for that. • A collection of bitwise-or'ed flags. Use 0 to block until the target's termination A simpler way to wait for any child process is to use the wait: pid_t wait (int *status) • This function waits until any of the child processes finish • Excellent when there are many children and you want to wait for them in the order they finish.

Concurrent Processes

Two processes run concurrently (are concurrent) if their flows overlap in time. Otherwise, they are sequential Control flows for concurrent processes are physically disjoint in time (except on multi-core machines) However, we can think of concurrent processes as running in 'parallel' with each other

execlp()

execlp() is similar to execl(). However, execlp() uses the PATH environment variable to look for the file. Therefore, the path to the executable file is not needed.

execv()

execv() receives a vector of arguments that will be available to the executable file. In addition, the last element of the vector must be NULL.

State of a process

User view: A process is executing continuously In reality: Several processes compete for the CPU and other resources A process may be - running: it holds the CPU and is executing instructions - ready: it is waiting to get back on the CPU - blocked: it is waiting for some I/O event to occur

virtual memory

Virtual memory is an abstraction that provides each process with the illusion that it has exclusive use of the main memory. A virtual address space is a set of ranges of virtual addresses that the operating system makes available to a process. There is not enough computer memory for the address spaces of all running processes. The OS gives each running process the illusion that it has access to its complete (contiguous) address space. In reality, this view is virtual, in that the OS supports this view, but it is not really how the memory is organized. Instead, memory is divided into pages, and the OS keeps track of which ones are in memory and which ones are stored out to disk.

to avoid image overwrite

We need another function to create a separate Process container first using another function fork(), and then call execvp("ls").


संबंधित स्टडी सेट्स

Block 9: Module 6-9 Practice Questions

View Set

Chapter 42: Assessment and Management of Patients with Obesity

View Set

The Art of Public Speaking - Chapter 11

View Set

Chapter 12 Ears, Nose, Mouth, and Throat

View Set

Managerial Accounting (Chapter 14)

View Set