Created
January 30, 2020 23:39
-
-
Save jdeweese1/fa2833283ad5eef66419eebea1d9471e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Briefly define the following and discuss their major tradeoffs (advantages/costs). What problem are they addressing? | |
Kernel threads - Threads that are executed on the operating system level. They are more expensive than user level threads, due to overhead, involve more context switching. These are a good choice for processes that block frequently. | |
Multiprogramming - Allows for more than one task to be happening at a time. Can drasticilly speed up programs, allow for backround tasks. The code and implemenation is substantially more complex, can run into weird bugs (race conditions etc). | |
Address space - range of addressses that are available for a program to access. Using address space prevents programs from writing over restricted memory, preventing lots of errors. This is also more expensive and requires more overhead to decide which programs get access to memory sectors. | |
Buffered (asynchronous) I/O - Buffered IO acts as an intermeditary between a program and the medium it is reading/writing to. For instance if a program is writing only a single byte of data to a file at a time, that is inefficient, but if we instead redirect the program to a memory buffer we can wait until there is enough informaton to make it worth requsting access to the file, then write it. This saves time writing back and forth, but adds a bit of complexity. | |
Why is concurrency/asynchrony behavior a problem? | |
- Concurrency can be a problem because race conditions | |
- Asynchrony can lead to bad performance. | |
What is a thread? Why do we use them? | |
- A thread allows for concurrently running tasks in a program. For instance while I'm writing an email, my email client can be pulling new mail via another thread. | |
- We use them because they allow for doing multiple tasks in a single program, and improve responsiveness, simplify code, increase efficency. | |
What is an operating system? (This will be question 1a on the final. Miss it and I will flunk you.) | |
- Control Program & Resource Allocator | |
What is the difference between a process and a thread? | |
- A process is an active version of a program. A process can have many threads, but a thread can't really have multiple processes. | |
- A thread is a smaller unit of multiprogramming. | |
Why is having the same file-oriented interface for both file I/O and console I/O an advantage? | |
- The program doesn't have to worry about whether its running in an interactive session or as part of an automated script. When the program wants to print text, it can just print to STDOUT, and the calling layer gets to redirect the output if needed. If in an interactive session, the program prints to screen, but can also just print to a file with little extra effort, to capture the log. | |
Why would (6) potentially also be a disadvantage? | |
- If a program can't tell that its running in a script, and doesn't terminate, it could create huge, unmanagable log files full of non-useful information. Where as if were just printing to the console it would still be producing the same amount of data, but that data would be eaten by the garbage collector. | |
Why would letting the compiler define a process’ address space be more appropriate than the OS? | |
- ??? | |
If you were designing a system with a web server connected to a database, would you use multiple processes or multiple threads and why? | |
- Likely both. You would give each server and each database its own process, and each of those processes would likely have threads its managing. | |
- Because the servers and database executables are different programs, they need their own processes. They would be best having many threads, because for instance the server will need to be responding to many clients simulatenously. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment