chapter 2 Flashcards

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
Q

how do we attach to a shared memory seg?

A

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
Q

how do we detach from a shared memory seg?

A

int shmdt (const void *shmaddr);
- returns 0 in success -1 in failure

26
Q

how do we destroy a shared memory seg?

A

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
Q

why is multi-threading better than multi-processing?

A
  • 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
Q

what are standard unix threads in c?

A

posix ( p ) threads

29
Q

how is multithreading done in c?

A

c has no built in multithreading support, so the OS has to provide this feature

30
Q

how does a pthread stop?

A
  • its process stops
  • its parent thread stops
  • its start function stops
  • it calls pthread exit
31
Q

what thread doesn’t stop even after its parent thread does?

A

detached thread

32
Q

what synchronization concepts do pthreads use?

A
  • mutex & condition variables
33
Q

how does multithreading work in java?

A
  • java has built in support for threading since threads are a native feature
34
Q

to what are java threads mapped?

A
  1. to OS - native threads
  2. to user space - green threads
35
Q

how is synchronization achieved in java threads?

A
  • using monitors [ similar to mutex ]
  • using conditional variables
36
Q

how do conditional variables work in java threads?

A
  • there are no explicit conditional vars in java, but we can explicitly block a thread
37
Q

how do we explicitly block and unblock threads in java?

A
  • wait () - current thread blocks
  • notify () - wakes up a thread waiting on a monitor
  • notifyAll () - wakes up all threads waiting
38
Q

what is Goroutine?

A

is a light weight thread function that executes independently and simultaneously with other go routines in a program

39
Q

what are concurrently executing activities in Go?

A

go routines

40
Q

how are go routines managed?

A

by the go runtime

41
Q

what is the r/n ship b/n go routines and shared memory?

A
  • since go routines run in the same address space, shared memory must be synchronized.
42
Q

compare and contrast between go routines and threads.

A

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
Q

what is virtualization?

A

virtualization is the technique of creating external interfaces that abstract computer resources.

44
Q

what are the roles of virtualization in DS?

A
  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
Q

what are the architectures of VMs?

A
  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