chapter 2 Flashcards
(46 cards)
what is a virtual processor?
is a simulated processor built on top of the physical processor by the OS
what is a processor?
provides instructions along with the capability to execute them
what is a thread?
a single path of execution in a process. a process can contain multiple threads
what is a process?
a program in execution that can execute 1 or more threads
what are benefits of multithreading?
- hides network latencies [ program executes d/t thread when a thread blocks when ]
- resource sharing
what things is a process made up of?
- pid
- pc
- 1 executing program
- memory
- signal handlers
how is pid determined?
A process can determine:
- its own pid - pid_t getpid (void);
- pid of its parents - pid_t getppid (void);
how is pid determined?
A process can determine:
- its own pid - pid_t getpid (void);
- pid of its parents - pid_t getppid (void);
how is a process created?
only by another process
how can we differentiate between a parent and child process?
fork() returns:
- 0 to the child
- pid of child to parent
- -1 if error occurs
what does fork() do?
creates a child that is the exact copy of parent process, and hence executes the same program
what does exec() do?
allows a process to switch execution to a d/t program
when does a process stop?
- when the main() function returns
- when a program calls exit()
how can a process stop another process?
- by sending a signal to it
- SIGINT stops a process (ctrl + c)
what does a signal do?
notifies a process that a particular event has occurred
list some examples of signals.
SIG:
- SEGV - seg fault
- BUS - bus error
- PIPE - trying to write to a disconnected pipe
- CHLD - child process has stopped
- USR1, USR2 - generic signal used by user programs
why can’t processes influence eachother?
they are executed in isolation from each other
why can’t processes influence eachother?
they are executed in isolation from each other
in what ways can interprocess communications take place?
Through:
- semaphores
- pipes
- shared memory
- signaling
what is a pipe?
- a unidirectional communication channel between 2 processes.
- 1 can read from it and 1 can write to it
what type of processes can a pipe link?
those that share a parent since they’d inherit a file descriptor
what is shared memory?
- is an IPC technique that allows processes to access the same memory area.
how to use shared memory?
- create shared memory segment - shmget()
- attach process to segment - shmat()
- detach process from segment - shmdt()
- perform operations on seg - shmctl()
how do we create a shared memory seg?
int shmget (Key_t key, int size, int shmflg);
- key: will be used by children processes
- size: size in bytes of segment
- shmflg: access control mask
- returns: shmid if successful or -1 if not