chapter 2 Flashcards

(46 cards)

1
Q

what is a virtual processor?

A

is a simulated processor built on top of the physical processor by the OS

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

what is a processor?

A

provides instructions along with the capability to execute them

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

what is a thread?

A

a single path of execution in a process. a process can contain multiple threads

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

what is a process?

A

a program in execution that can execute 1 or more threads

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

what are benefits of multithreading?

A
  • hides network latencies [ program executes d/t thread when a thread blocks when ]
  • resource sharing
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

what things is a process made up of?

A
  • pid
  • pc
  • 1 executing program
  • memory
  • signal handlers
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

how is pid determined?

A

A process can determine:
- its own pid - pid_t getpid (void);
- pid of its parents - pid_t getppid (void);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

how is pid determined?

A

A process can determine:
- its own pid - pid_t getpid (void);
- pid of its parents - pid_t getppid (void);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

how is a process created?

A

only by another process

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

how can we differentiate between a parent and child process?

A

fork() returns:
- 0 to the child
- pid of child to parent
- -1 if error occurs

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

what does fork() do?

A

creates a child that is the exact copy of parent process, and hence executes the same program

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

what does exec() do?

A

allows a process to switch execution to a d/t program

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

when does a process stop?

A
  • when the main() function returns
  • when a program calls exit()
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

how can a process stop another process?

A
  • by sending a signal to it
  • SIGINT stops a process (ctrl + c)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

what does a signal do?

A

notifies a process that a particular event has occurred

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

list some examples of signals.

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

why can’t processes influence eachother?

A

they are executed in isolation from each other

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

why can’t processes influence eachother?

A

they are executed in isolation from each other

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

in what ways can interprocess communications take place?

A

Through:
- semaphores
- pipes
- shared memory
- signaling

19
Q

what is a pipe?

A
  • a unidirectional communication channel between 2 processes.
  • 1 can read from it and 1 can write to it
20
Q

what type of processes can a pipe link?

A

those that share a parent since they’d inherit a file descriptor

21
Q

what is shared memory?

A
  • is an IPC technique that allows processes to access the same memory area.
22
Q

how to use shared memory?

A
  • create shared memory segment - shmget()
  • attach process to segment - shmat()
  • detach process from segment - shmdt()
  • perform operations on seg - shmctl()
23
Q

how do we create a shared memory seg?

A

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
24
how do we attach to a shared memory seg?
void *shmat (int shmid, const void *shmaddr, int shmflg); - shmid - returned from shmget() - shmaddr - specifies attaching address of seg, NULL if idc - shmflg - access control mask
25
how do we detach from a shared memory seg?
int shmdt (const void *shmaddr); - returns 0 in success -1 in failure
26
how do we destroy a shared memory seg?
int shmctl (int shmid, int cmd, struct shmid_ds *buf); - cmd - command - shared memory persist even after processes have died so they must be destroyed
27
why is multi-threading better than multi-processing?
- threads share processes' memory, files, instruction & signal handlers - a process can execute multiple threads - thread communication is easier - threads have their own id and pc - threads have special synchronization primitives
28
what are standard unix threads in c?
posix ( p ) threads
29
how is multithreading done in c?
c has no built in multithreading support, so the OS has to provide this feature
30
how does a pthread stop?
- its process stops - its parent thread stops - its start function stops - it calls pthread exit
31
what thread doesn't stop even after its parent thread does?
detached thread
32
what synchronization concepts do pthreads use?
- mutex & condition variables
33
how does multithreading work in java?
- java has built in support for threading since threads are a native feature
34
to what are java threads mapped?
1. to OS - native threads 2. to user space - green threads
35
how is synchronization achieved in java threads?
- using monitors [ similar to mutex ] - using conditional variables
36
how do conditional variables work in java threads?
- there are no explicit conditional vars in java, but we can explicitly block a thread
37
how do we explicitly block and unblock threads in java?
- wait () - current thread blocks - notify () - wakes up a thread waiting on a monitor - notifyAll () - wakes up all threads waiting
38
what is Goroutine?
is a light weight thread function that executes independently and simultaneously with other go routines in a program
39
what are concurrently executing activities in Go?
go routines
40
how are go routines managed?
by the go runtime
41
what is the r/n ship b/n go routines and shared memory?
- since go routines run in the same address space, shared memory must be synchronized.
42
compare and contrast between go routines and threads.
Go routines: - have a faster startup - have no id - are cooperatively scheduled [ not preemptively ] - have lower latencies - are hardware independent - managed by go runtime [ not the kernel ] - have easier communication mediums - have growable segment stacks
43
what is virtualization?
virtualization is the technique of creating external interfaces that abstract computer resources.
44
what are the roles of virtualization in DS?
1. hardware changes faster than faster than software, hence SW can't be maintained in the same pace as platforms it relies on. - virtualization can solve this by porting SW to new platforms 2. virtualization creates ease of portability and code migration. 3. virtualization isolates failing or attacked components.
45
what are the architectures of VMs?
1. general instruction - interface b/n HW and SW, invoked by any program. 2. privileged instruction - interface b/n HW and SW, invoked by privileged programs [ like the OS] 3. system calls - interface b/n OS and library 4. API - interface b/n library calls and application layer