You are not logged in. Your edit will be placed in a queue until it is peer reviewed.
We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.
Required fields*
-
14This answer could benefit from additionally explaining of why splitting programs into many small ones saves memory use: A program had to be able to fit in-memory to run, but only the currently running program. Every other program was swapped out to disk in early Unix, with only one program even swapped into actual RAM at a time. So the CPU would run one program, which would write to a pipe (which back then was on disk), swap out that program and swap in the one that read from the pipe. Elegant way to turn a logically parallel assembly line into incremental serialized execution.mtraceur– mtraceur2018-06-20 17:06:20 +00:00Commented Jun 20, 2018 at 17:06
-
6@malan: Multiple processes can be started and can be in a runnable state at the same time. But at most one process can be executing on each physical CPU at any given time, and it's the job of the kernel's process scheduler to allocate "slices" of CPU time to each runnable process. In modern systems, a process that is runnable but not currently scheduled a CPU timeslice usually remains resident in memory while it's waiting for its next slice, but the kernel is allowed to page the memory of any process out to disk and back into memory again as it finds convenient. (Handwaving some details here.)Daniel Pryden– Daniel Pryden2018-06-20 19:09:56 +00:00Commented Jun 20, 2018 at 19:09
-
5Processes on either side of a pipe can behave effectively like co-routines: one side writes until it fills up the buffer and the write blocks, at which point the process can't do anything with the rest of its timeslice and it goes into an IO wait mode. Then the OS gives the remainder of the timeslice (or another upcoming timeslice) to the reading side, which reads until there's nothing left in the buffer and the next read blocks, at which point the reader process can't do anything with the rest of its timeslice and yields back to the OS. Data goes through the pipe one buffer's worth at a time.Daniel Pryden– Daniel Pryden2018-06-20 19:13:30 +00:00Commented Jun 20, 2018 at 19:13
-
6@malan The programs are started "at the same time" conceptually on all Unix systems, just on modern multiprocessor systems with enough RAM to hold them that means they're literally all held in RAM at the same time, while on a system that can't hold them all in RAM at the same time, some get swapped out to disk. Also note that "memory" in a lot of contexts means virtual memory which is the sum of both RAM space and swap space on disk. Wikipedia is focusing on the concept rather than on the implementation details, especially because how really old Unix did things is less relevant now.mtraceur– mtraceur2018-06-20 21:28:15 +00:00Commented Jun 20, 2018 at 21:28
-
2@malan Also, the contradiction you are seeing comes from the two different meanings of "memory" (RAM vs RAM+swap). I was talking about hardware RAM only, and in that context only the code currently being executed by the CPU needs to fit in RAM (which was what was effecting the decisions Kernighan is talking about), while in the context of all programs being logically executed by the OS at a given time (at the abstract level provided on top of time slicing) a program just needs to fit within the entire virtual memory available to the OS, which includes swap space on disk.mtraceur– mtraceur2018-06-20 21:40:19 +00:00Commented Jun 20, 2018 at 21:40
|
Show 15 more comments
How to Edit
- Correct minor typos or mistakes
- Clarify meaning without changing it
- Add related resources or links
- Always respect the author’s intent
- Don’t use edits to reply to the author
How to Format
-
create code fences with backticks ` or tildes ~
```
like so
``` -
add language identifier to highlight code
```python
def function(foo):
print(foo)
``` - put returns between paragraphs
- for linebreak add 2 spaces at end
- _italic_ or **bold**
- indent code by 4 spaces
- backtick escapes
`like _so_` - quote by placing > at start of line
- to make links (use https whenever possible)
<https://example.com>[example](https://example.com)<a href="https://example.com">example</a>
How to Tag
A tag is a keyword or label that categorizes your question with other, similar questions. Choose one or more (up to 5) tags that will help answerers to find and interpret your question.
- complete the sentence: my question is about...
- use tags that describe things or concepts that are essential, not incidental to your question
- favor using existing popular tags
- read the descriptions that appear below the tag
If your question is primarily about a topic for which you can't find a tag:
- combine multiple words into single-words with hyphens (e.g. shell-script), up to a maximum of 35 characters
- creating new tags is a privilege; if you can't yet create a tag you need, then post this question without it, then ask the community to create it for you