Week 2 Flashcards

(71 cards)

1
Q

3 Main OS Tasks

A
  1. Virtualize Resources
  2. Managing I/O
  3. Making the above easy
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What does mediate mean

A

processes cannot interfere with each other

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

What an OS Looks like

A

Programs/process <-> OS <-> CPU/RAM/Device Drivers

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

What is batch mode?

A

submit a large computaion, wait for result, then submit another one

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

What did even early machines have?

A

Libraries of functions (common I/O functions)

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

In the 1960 breakthrough, what was implemented

A

Separation, given the OPTION to use programs

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

3 ways to implement separation for CPU Virtualization

A
  1. Give CPU 2 execution modes
  2. Define a trap –> an instruction to switch into OS code and back
  3. Ring of fire –> More flexibility
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What are the different Ring of Fire levels

A

Level 0: OS/ Kernel
Level 3: Processes/apps

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

What enabled Multiprogramming?

A

Memory protection: allowing programs to share a memory / see their own area for memory through VIRTUAL MEMORY

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

What is CPU Virtualization

A

The art of “slicing” a CPU. An OS should be able to:
1. run and stop a program
2. decide which program should run
3. divide CPU time fairly

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

What is Memory Virtualization

A

Gives every process the same VIRTUAL ADDRESS SPACE
Each process gets the illusion of having the memory to itself.
Virtual address is mapped to the physical space.
Mapping can change and isn’t always 1:

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

Difference between Concurrency and CPU Virtualization

A

CPU Virtualization gives the “illusion” of concurrency by taking turns.

Concurrency: Different parts of A SINGLE program cooperate to complete a task.

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

What 2 requirements for Concurrency?

A
  1. Different parts of the program are able to communicate
  2. Ability to synchronize access to shared data
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Virtual Memory vs Shared Disk?

A

Virtual Memory: works because processes mostly need their own memory space and only sometimes need to share MEMORY data

Shared Disk: Works because it is very common for programs to use / share DISK data

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

What is a command line?

A

Provided by a utility called a shell, it runs the terminal

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

What is a shell?

A

A program that presents a prompt and waits for text commands

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

What are commands?

A

Names of executable programs that you want to run.

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

Detailed Steps of how a shell command works.

A
  1. files are compiled programs called binaries
  2. OS loads the binary into memory and executes it
  3. OS stores metadata about each process (process ID / PID)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What are binaries

A

compiled programs

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

What is a process?

A

An executing program/binary. A program that is being executed.

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

What are shell environment variables

A

Stores configuration information and values for the shell. Which modifies the behavior of the shell.

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

How are shell metadata stored?

A

Stored as KEY-VALUE pairs. Each pair represents a variable and a value.

Ex: “VAR1_NAME = VAR1_VALUE”

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

Who can modify/read variables?

A

Shell, programs, and the user

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

what is PATH

A

Tells the shell which folder it should look for in programs.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
What is a Working directory?
The place (by default) where programs and data will be looked for. Actions on the command depend on the context of where they are run.
26
Can you run a command in any directory?
Yes, by specifying the FULL / absolute path.
27
Pipe Operand
the " cmd1| cmd2" symbol. Executes the code of cmd1 and takes that output into cmd2
28
command line that prints a string to terminal
$echo
29
when shell encounters these it replaces it with the variable of the value that follows
$
30
looks for a program called mycmd in the CURRENT directory and run it
$./mycmd
31
command line utility that prints current working directory
$pwd
32
command line utility to change the working directory
$cd
33
command line utility to go up the parent directory
$cd ../
34
print the content of into the ternimal
$cat
35
command line utility used for string replacement in the files (used alongside regex)
$sed
36
What file-like objects open whenever a program starts?
1. standard output 2. standard input 3. standard error
37
How to access standard input? (code)
Through the “read” function. bytesread = read(0, input, sizeof(input)) if (bytesread < 1) return -1;
38
How to access standard output? (code)
Through the “write” function. write(1, input, strlen(input) - 1) // output the stuff received by the input
39
command to search for a string in each line of input
$grep
40
command to count the number of characters/words/lines in the input
$wc
41
command to save standard OUTPUT to a new file, filename
command > filename
42
command to save standard ERROR to a new file, filename
command 2> filename
43
command to APPEND to an EXISTING file.
command >> filename
44
command to redirect the standard error to the standard output
2>&1
45
command to redirect the standard output to standard error
1>&2
46
What are Manual (man) pages
- Describes different command line utilities and their options - Standard C/C++ functions - Can be accessed with $man
47
What does grep do?
parses a file / standard input and return ALL LINES THAT MATCH (or do not match) a string.
48
A few grep parameters
-i: case insensitive -v: return lines that do NOT match -c: print number of matching lines per file -l: print names of files with matches
49
What is a regular expression?
a pattern that describes a set of strings and uses special characters to describe sets of characters in a string.
50
a regex to match any character ex: matches "a1b", "aAb", "a-b", etc.
. ex: a.b
51
A regex to match a sequence of any length of the preceding character ex: matches "", "a", "aa", "aaa", etc
* ex: a*
52
A regex to match one or more of the preceding characters ex: matches "a", "aa", "aaa", but not ""
+ ex: a+
53
A regex to match zero or one occurence of the preceding character ex: "", "a"
? ex: a?
54
a regex that matches any single character from a set of characters ex:matches "a", "b", or "c"
[] ex: [abc]
55
a regex to match any character within a range ex: matches any lowercase letter from "a" to "z"
[a-b] ex: [a-z]
56
a regex that matches either one pattern or the other ex: matches "cat" or "dog"
( | ) ex: (cat|dog)
57
file system operation to create an empty file
touch
58
file system operation to display size of files
du
59
text processing command to extract fields from content
cut
60
text processing command to invert text
rev
61
text processing command to parce/process text
awk
62
text processing command to sort all input lines numerically/alphabetically
sort
63
text processing command to remove all dupe lines
uniq
64
What 2 types of programs can shell run and how?
Executable Files Interpreted Scripts All ran with $./program_name
65
What are Interpreted Scripts?
A bunch of text which gets passed as an input to an interpreter.
66
What are the UNIX Permissions and to what entities?
Each file has 3 permissions: read, write, execute Each permission can be specified for 3 entities: user, group, all users
67
Does each script must be given permission to execute?
Yes. Use chmod $ chmod a+x [.sh file]
68
What do the back-ticks in shell programming mean? ` `
"replace the string with the output of the expression"
69
How to do expressions in shell programming?
expr keyword VAR = `expr $VAR + 1`
70
Basic structure of conditional blocks for shell programming?
if [ ] then fi --> specifies the end of a conditional block
71
Basic structure for loops in shell programming?
while [ ] do loops done to specify the end of a loop block.