SRE Questions Flashcards

1
Q

What is the difference between a process and a thread?

A
  • Thread is a light weight process
  • threads have their own stack, but share these with the parent process
    • text (program code)
    • data (program input)
    • heap (stores files, locks, sockets)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is a zombie process?

A
  • has completed execution
  • still in the process table so the parent can read the child’s exit status
  • it’s dead, but not yet reaped by it’s parent
  • when a parent makes a system call to read the exit status, then the process is removed
  • kill doesn’t work on zombie processes
  • don’t take up system resources
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How to get rid of a zombie process?

A
  • killing the parent should work to eliminate a zombie. (pid 1 will own it and then kill it)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How do you end up with zombie processes?

A
  • created if the parent process doesn’t reap the child
  • can happen if the parent doesn’t execute the wait() system call after forking
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How does the system daemonize a process?

A

The fork() call is used to create a separate process.
The setsid() call is used to detach the process from the parent (normally a shell).
The file mask should be reset. The reason for this is because we want to create new files with the mask that is needed for the child process.
The current directory should be changed to something benign. We may not want the child to be in the same pwd as the parent.
The standard files (stdin,stdout and stderr) need to be reopened.

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

Describe ways of process inter-communication

A

Shared memory - threads share memory inside a process
POSIX mmap - a system call that maps files or devices into memory
Message queues - they allow multiple processes to read/write to the message queue without being directly connected
socket - sends streaming data over a network interface
pipes - these direct input/output of one process to another
Unix domain sockets - similar to an internet socket, but all communication occurs within the kernel. Use the file system as their address space.
RPC - remote procedure call
File - multiple processes can read/write
http://en.wikipedia.org/wiki/Inter-process_communication

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

What is a system call that maps files or devices into memory? _____ _____

A

POSIX mmap

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

Does the OS have message queues?

A

Yes - they allow multiple processes to read/write to the message queue without being directly connected

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

____ sends streaming data over a network interface

A

socket - sends streaming data over a network interface

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

What does a Unix domain socket do?

A

They are similar to an internet socket, but all communication occurs within the kernel. Use the file system as their address space.

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

___ ___ ___ is when a computer program causes a procedure to execute in a different address space (this computer or another computer over a network) which is coded as if it were a normal procedure call without the programmer explicitly coding the details for the remote interaction.

It is also a form of inter-process communication, in that different processes have different address spaces: if on the same host machine, they have distinct virtual address spaces, even though the physical address space is the same; while if they are on different hosts, the physical address space is different.

A

RPC - remote procedure call

https://en.wikipedia.org/wiki/Remote_procedure_call

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

Describe how processes executes in a Unix shell

A

Example /bin/ls
- when you run ‘ls’
- the shell searches the path for an executable named ls
- the shell process forks off a copy of itself
- if the fork succeeds, then it will run the full executable path it found with ‘exec /bin/ls’.
This replaces the copy of the child shell with itself. Parameters passed in are also run by exec.

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

What are unix signals?

A

Signals are a way the OS communicates with processes.

The ‘kill’ command is used to send signals to a process.

Example signals:

SIGTERM 15 (optional - default signal to send with kill)
SIGINT 2 Term Interrupt from keyboard
SIGQUIT 3 Core Quit from keyboard
SIGKILL 9 Term Kill signal (not optional)
SIGSTOP 17,19,23 Stop Stop process
SIGPIPE 13 Term Broken pipe: write to pipe with no
readers

The signals SIGKILL and SIGSTOP cannot be caught, blocked, or
ignored.

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

What does ‘echo $?’ tell you?

A

This is the exit code from the last run process

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

When you send a HUP signal to a process, you notice that it has no impact, what could have happened?

A

During critical section execution, some processes can setup signal blocking. The system call to mask signals is ‘sigprocmask’. When the kernel raises a blocked signal, it is not delivered.

Such signals are called pending. When a pending signal is unblocked, the kernel passes it off to the process to handle. It is possible that the process was masking SIGHUP.

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

What is TCP slow start?

A

A congestion control algorithm which balances the speed of a network connection. It starts slowly and gradually increases the amount of data transmitted until it finds the network’s maximum carrying capacity. It knows it’s reached the limit when ACK is no longer recieved.

This is used when two computers over the network start to communicate. During the TCP handshake.

Benefits:
- Users experience uninterrupted connections since packets are no longer dropped due to congestion.
- Users also experience faster downloads since slow start finds and uses the maximum connection speed.
- Enterprises see less network congestion since slow start regulates bandwidth and prevents the sender from having to continuously retransmit data.

17
Q

List 4 TCP connection states

A

1) LISTEN – Server is listening on a port, such as HTTP
2) SYN-SENT – Sent a SYN request, waiting for a response
3) SYN-RECEIVED – (Server) Waiting for an ACK, occurs after sending an ACK from the server
4) ESTABLISHED – 3 way TCP handshake has completed

18
Q

What is DHCP?

A

Dynamic host configuration protocol
A network management protocol used to automate the process of configuring devices on IP networks. The server doesn’t have an IP at this point, but can also receive either a dynamic IP or static IP (manually configured).

Data assigned:
- subnet mask
- router
- DNS server
- hostname
- domain name

Benefits
- less toil
- IP addresses are automatically freed up
- Don’t need a network admin to setup each server

19
Q

What are some protocol states of DHCP?

A

DHCP DISCOVER client->server : broadcast to locate server
DHCP OFFER server->client : offer to client with offer of configuration parameters
DHCP REQUEST client->server : requesting a dhcp config from server
DHCP ACK server->client : actual configuration paramters
DHCP NAK server->client : indicating client’s notion of network address is incorrect
DHCP DECLINE client->server : address is already in use
DHCP RELEASE client->server : giving up of ip address
DHCP INFORM client->server : asking for local config parameters

These are all one word, but I added spaces for readability.

20
Q

Describe TCP header format

A

Source port
Destination port
Sequence number
Acknowledgement number
Data offset
Reserved
Control bits
Window
Checksum
Urgent Pointer
Options
Padding
Data