CSCI 315 Operating Systems Designhttp://www.eg.bucknell.edu/~cs315/wordpress
Department of Computer ScienceWed, 05 Dec 2018 18:48:33 +0000en-UShourly1http://wordpress.org/?v=3.5Boot Sequence Noteshttp://www.eg.bucknell.edu/~cs315/wordpress/boot-sequence-notes/
http://www.eg.bucknell.edu/~cs315/wordpress/boot-sequence-notes/#commentsTue, 29 Aug 2017 11:55:06 +0000Joshua Stoughhttp://www.eg.bucknell.edu/~cs315/wordpress/?p=1862This class centered around the boot sequence. On getting to understand the hardware pieces mentioned in boot: I found this link very helpful and informative with the virtual tour link that gives a nice overview as well as many other internal links going into more specifics depending on what pieces of hardware I wanted to [...]]]>

This class centered around the boot sequence.

On getting to understand the hardware pieces mentioned in boot: I found this link very helpful and informative with the virtual tour link that gives a nice overview as well as many other internal links going into more specifics depending on what pieces of hardware I wanted to read more about.

A Few Big OS Concepts

What does the OS do?
Provides the interface between the user/application and the hardware.
This is done through System calls, or the library functions that call them. There are system calls for pretty much everything you (or a program) can ask the hardware to do (process instantiation, memory allocation, file I/O, device I/O, network communication, …).
A complementary view is that the OS manages limited hardware resources, given all the various running apps and their demands.

User mode vs Kernel mode
No user program has direct access to the hardware. For example the user program cannot just decide to keep the CPU for its own purposes. This is one reason why there is kernel mode.

Device Driver vs Controller
The driver is software whereas the controller is usually circuitry that is part of the hardware the driver is ‘driving.’ Think if you’re driving a car, you’re the driver. You want to accelerate (or someone else tells you to). Whatever magic is connected to the other side of the accelerator pedal is the controller.

Mechanism vs Policy : How things get done, versus deciding which things can be done/to do and when. An important distinction in operating system design. Read more.

]]>http://www.eg.bucknell.edu/~cs315/wordpress/os-concepts/feed/0C is still big. In fact #1 in 2016.http://www.eg.bucknell.edu/~cs315/wordpress/c-is-still-big-in-fact-1-in-2016/
http://www.eg.bucknell.edu/~cs315/wordpress/c-is-still-big-in-fact-1-in-2016/#commentsFri, 19 Aug 2016 18:40:01 +0000adminhttp://www.eg.bucknell.edu/~cs315/wordpress/?p=1592The IEEE Spectrum magazine just published the list of the most popular programming languages in 2016. Follow the hyperlink to read more about it. ]]>

]]>http://www.eg.bucknell.edu/~cs315/wordpress/c-is-still-big-in-fact-1-in-2016/feed/0Recovering code from githttp://www.eg.bucknell.edu/~cs315/wordpress/recovering-code-from-git/
http://www.eg.bucknell.edu/~cs315/wordpress/recovering-code-from-git/#commentsThu, 17 Oct 2013 18:52:12 +0000adminhttp://www.eg.bucknell.edu/~cs315/wordpress/?p=664At one point or another people goof and mess up their codebase beyond the repair of a quick fix. If you have been good about committing your code to your git repository periodically, you can easily go back to one of your previous versions.

There are two commands to restore a working copy of a [...]]]>

At one point or another people goof and mess up their codebase beyond the repair of a quick fix. If you have been good about committing your code to your git repository periodically, you can easily go back to one of your previous versions.

There are two commands to restore a working copy of a previously committed revision: git resetand git checkout. Take a look at this to learn how to make them work for you.

]]>http://www.eg.bucknell.edu/~cs315/wordpress/recovering-code-from-git/feed/0Using Pointers as Array Nameshttp://www.eg.bucknell.edu/~cs315/wordpress/using-pointers-as-array-names/
http://www.eg.bucknell.edu/~cs315/wordpress/using-pointers-as-array-names/#commentsMon, 02 Sep 2013 11:03:37 +0000adminhttp://www.eg.bucknell.edu/~cs315/wordpress/?p=437It made me very excited that some students reported taking my advice to “test things out in the small” by writing programs to evaluate nebulous ideas in C programming. They reported to me that something we discussed in class wasn’t accurate, so this post brings you an update on it.

When you try to use [...]]]>

It made me very excited that some students reported taking my advice to “test things out in the small” by writing programs to evaluate nebulous ideas in C programming. They reported to me that something we discussed in class wasn’t accurate, so this post brings you an update on it.

When you try to use a pointer as an array name, after having assigned it a chunk of memory dynamically allocated, you can use the indexing square brackets to get to individual characters, as in the lines marked (1) in the program below. If you try to deference the pointer first and then index into the array, as in the lined marked (2) below, you get compile time errors. Note that to get this program to compile, you have to comment out the lines marked (2) or remove them from the program altogether.

As you can see, it’s easy to goof when playing with pointers in C. Do as these students did and try things out as much as possible before you accept them as facts. The punchline here is that your professors can makes mistakes, too!

Another interesting point you can learn from this program is that if you are not going to use command line parameters in your code, you can use argument void in your main function. This saves you a bit of typing the boiler plate code int argc, char* argv[].

]]>http://www.eg.bucknell.edu/~cs315/wordpress/using-pointers-as-array-names/feed/0Heap Copying from Parent to Childhttp://www.eg.bucknell.edu/~cs315/wordpress/heap-copying-from-parent-to-child/
http://www.eg.bucknell.edu/~cs315/wordpress/heap-copying-from-parent-to-child/#commentsFri, 01 Feb 2013 14:22:38 +0000adminhttp://www.eg.bucknell.edu/~cs315/wordpress/?p=118We recently had a problem in a pre-lab that tried to answer the question of whether dynamically allocated data would be shared between parent and child processes. The actual heart of the question is whether, after a fork, a parent and its child processes would share a single heap. If this were true, any changes [...]]]>

We recently had a problem in a pre-lab that tried to answer the question of whether dynamically allocated data would be shared between parent and child processes. The actual heart of the question is whether, after a fork, a parent and its child processes would share a single heap. If this were true, any changes one process would make to malloc’ed data would become immediately visible to all other processes.

To verify what happens in Linux, one could put together a program like this:

From the start of the output, we learn that the child inherited “something” from the parent: it got a heap with the same original content. The open question is whether this heap is a copy or if it’s shared memory. Looking at what happens to the values printed after parent and child change the contents of (*p), we see that we must be talking about disjoint areas of memory. That is, the heap is copied after fork, but parent and child have their own separate heaps.

Now, that “conclusion” gets muddied when we look at the memory addresses of the malloc’ed integer, that is the address stored in pointer p: it is exactly the same for both parent and child. It’s fair for one to ask how it’s possible that with addresses being the same, we get the behavior of having different memory locations for the two heaps. One thing we can be sure of: this doesn’t happen by magic. The answer involves copy-on-write semantics and virtual memory, as we see in this StackOverflow post. This goes back to what we should understand as the “context” of a running process.

The calls to sleep are a bit of overzealousness, but they are there to demonstrate to the observer that the child has a chance to store value 4 in the supposedly shared memory area well before the parent has chance to set it to 0.

]]>http://www.eg.bucknell.edu/~cs315/wordpress/heap-copying-from-parent-to-child/feed/0C Array/String Initializationhttp://www.eg.bucknell.edu/~cs315/wordpress/c-array-initialization/
http://www.eg.bucknell.edu/~cs315/wordpress/c-array-initialization/#commentsThu, 31 Jan 2013 00:49:04 +0000adminhttp://www.eg.bucknell.edu/~cs315/wordpress/?p=99A question came up in lab today about what happens with the following C line at compilation and at run time: [crayon-5c93ca829b4bb646630767/] People doubted that the effect of this line would be to reserve space in memory for 80 char and initialize the first six of them with: [crayon-5c93ca829b4c4008817146/] So, in order to settle this [...]]]>

A question came up in lab today about what happens with the following C line at compilation and at run time:

char str[80] = "hello";

People doubted that the effect of this line would be to reserve space in memory for 80 char and initialize the first six of them with:

does indeed allocate (in the data segment) space for 80 char and initializes the first six to:

{'h', 'e', 'l', 'l', 'o', 0}

In fact, what it does is to initialize the first 5 positions with ‘h’, ‘e’, ‘l’, ‘l’, ‘o’ and all the remaining 75 elements of the array with byte value 0. This observation is consistent with what I found at: