


Here are some comments on selected answers to the midterm.


If my academic goals for the course do not coincide with your personal
goals, what should you do?

>_Well, if I don’t think that “becoming a better programmer” with a better
understanding of how computers work and don’t realize that computers are
“intellectually, culturally, and scientifically interesting,” I should
probably just quit studying computer science. According to Prof. Evans,
though, I should meet with him to figure out an alternative._ (Andrew Yang)

What is a process?

>_A process is an abstraction for owning the entire machine at one
point, meaning that it’s an instance of a running computer program that
has its own machine state (stack, registers), program counter, access to
resources, and an isolated memory space. The operating system allocates
resources to processes to make sure they can complete and proceed
without failure, so as to guarantee better stability to the user of the
OS and to other running processes._ (Jake Kenneally)

How many processes should a web browser create?

> _Past browsers would only create one process in order to decrease the
  amount of memory and CPU, which was more expensive and limited at the
  time.  Single process browsers were okay in the past because most of
  the internet consisted of static web pages.  However, web content has
  evolved to contain more active code that runs within the browser,
  making web sites behave more like applications than documents.  These
  new characteristics of the web changed the browser and modified its
  role to behave more like an operating system than a document parser
  and renderer. 

Google Chrome was one of the first browsers to have multiple processes.
The types of processes can be broken up into four categories: browser,
render, plugin, and extension.   By default, chrome makes a new process
per instance of a site a user visits.  This ensures that the pages from
different sites are rendered independently; failures on one site will
not disable failures on another site.

Splitting into multiple processes can make the components of a browser
more isolated, handling site errors more cleanly and preventing
contention failures.  However, there is a tradeoff with memory overhead
and complexity of implementation.  A browser should use processes with
these advantages and tradeoffs in mind; if memory is expensive, a single
process browser may be the answer.  However, if safety and robustness
are key, multiprocess browsers would be more fitting._ (Justin
Washington)


> _This depends on the hardware and software being used. In the 1990s, the
answer was 1 process since processes waste memory and CPU. In the 2000s,
browsers like Google Chrome wanted to have one process for every tab
that was open, giving each tab its own memory and copy of global data
structures. This was meant to help web browsing both load faster and be
more secure against malware.
Today, Google Chrome still creates a separate process for each tab when
used on a desktop or laptop, but when using smartphones, which go back
to the problem of the 1990s of limited memory and processing power, it
is better to limit the number of processes being created.
In short, the answer is: it depends._ (Claire Ryberg)

> _A web browser should create enough processes to utilize all machine
  resources possible in order to provide a good browsing experience for
  the user. In the 1990s when memory was expensive, it made sense to
  create one process a browser. In the 2000s when memory became cheaper,
  it made more sense to create multiple processes for more
  robustness. This led to a design of one process per tab. With a
  process per tab, a crash in processing would only affect the tab
  instead of the whole browser itself.  Today, a browser should be able
  to utilize multiple processes for a single web page to take advantage
  of multi-core processors in a safe and robust manner. 

It’s near impossible to achieve with current languages though. Since the
languages were designed for machines with limited memory, they don’t
provide safe support and control over memory and concurrency. Hence, one
purpose of making Rust is to create a language with a memory model that
accounts for concurrency and has better support for parallel process
programming._ (Eric Tsai)

> _Web browsers vary in how many processes they create for many
  reasons. The chrome browser is notorious for creating a process for
  each tab open which can get to as many as 20 processes at a time. On
  the other hand the Mozilla web browser creates a few processes that
  take up a lot of memory. To answer the question of what is the optimal
  number to create, the costs and benefits of having a large amount of
  processes for a browser should be evaluated. Since processes take up
  memory and CPU usage and we want performance to be optimal as well as
  improve the user experience, there needs to be an optimal number of
  processes per machine. In the 1990’s, the memory space was minimal and
  there was only one CPU for the many machines thus creating one process
  was the best choice. Of course the one process had to be balanced in
  how much memory and CPU usage it took up otherwise it would still be
  sub optimal. On modern machines, having one process per browsing
  session would mean that the user experience is poor because of the
  potential of creating more processes for faster browsing is not
  achieved. Nowadays, a lot of computation is done on the client browser
  side through JavaScript so having more processes would help Javascript
  run faster. On the other hand it doesn’t make sense to create 20
  processes for pages that are all static. Mozilla creates a special
  plugin process that allows the main Firefox process to stay open if a
  plugin crashes so this extra process helps prevent annoying browser
  crashes. The entire browser can still freeze in Mozilla though if
  something is malfunctioning since there is one process per session. In
  chrome, if one tab fails, one can still keep browsing the other tabs
  while only that one tab is frozen. Then there is the type of machine
  the browser is running on to consider: a browser should know whether
  it is running on a 2 core iPhone 5c or a 4 core Galaxy S4 so that the
  number of processes doesn’t overwhelm the machine or underwhelm the
  user experience. Chrome has a general limit to the number of
  processes, 20, which may be good on only some machines but probably
  not on a mobile device. Some machines may handle more processes while
  others less. So the question as to how many processes should a web
  browser creates really depends on the machine architecture and the
  uses for those processes that the browser creates as well as what kind
  of pages the user is loading._ (Kristina Blokhin)


Why is there a fundamental tradeoff between maximizing resource
utilization and fairness in scheduling?

>_In class, we used the traffic light problem to explain the fundamental
 tradeoff between maximization resource utilization and fairness in
 scheduling.  Consider the intersection of a major highway with a small
 side road.  During rush hour, the way to maximize resources (ie
 maximize usage of the space of the intersection), the light for the
 large highway should always be green.  This case will allow the
 greatest number of cars to pass through the intersection; yet is
 extremely unfair for the cars which will have to wait for several hours
 for their chance to go.  However if the light was fair and gave the
 lesser process a share of the resources then fewer cars would be able
 to pass through the intersection.  A good scheduler must work to
 maximize resource utilization, achieve some level of fairness, and
 allow no starvation.  There are several different strategies for
 scheduling.  These include first come first serve, round robin, and
 priorities._ (Christina Giampalmo)

> _To put it most simply, fairness in scheduling requires switching
> between processes.  Switching between processes requires some amount
> of computation and storage of information about processes.  Therefore,
> resource use increases with the amount of switching that needs to be
> done.  If there’s no switching then there’s no fairness but at least
> very few resources need to be used.  On the other hand, if there’s
> plenty of switching you likely have a more fair system but you’ll need
> to do some amount of complex computing to decide when to switch and
> what information to store when you do.  To do more you must have
> more._ (Kevin McVey)

> _Maximizing resource utilization means using the maximum number of
  computing cycles on the processes them selves.  Fairness in scheduling
  requires processes to alternate frequently.  Alternating requires
  using computing cycles to switch the currently running process, this
  could include waiting for IO (caching/loading new data).  The more we
  switch processes the less we are utilizing resources hence the
  fundamental tradeoff._ (Evan Boyle)


Your technically unsophisticated (but smart, rich, and curious) uncle
complains that his laptop is too noisy since the fan is running all the
time.  He expects that as someone taking upper-level computing courses
at an elite, public university, you should be able to help him.  What do
you do?

> _Well, I'm glad you asked me! Before I had taken some of these classes I
would have just told you to go into your power options and manually set
the fan to quiet. Now, I can tell you that your issue is probably one of
software, and not hardware, and you can probably remedy it without too
much hassle! First off, I'm going to need to look at a few things to
make sure my guess is accurate. I'll walk you through what I'm
doing. So, the reason computers heat up is the same reason light bulbs
heat up, right? Electricity generates heat when it flows through a wire
with some resistance, so when a lot of electricity flows, a lot of heat
flows as well. Now, it may seem weird, but a lot of pieces of your
computer don't require much electricity to run, so we can narrow our
search right off the bat. We'll just look at your CPU, your GPU, and
your hard disk._ (Braden Wright)

>_I would explain to him that we have three basic kinds of processes:

1. Compute Bound
2. I/O Bound
3. Real-Time

If his fan is noisy it is probably because the processor is constantly
doing work, thus generating a lot of heat which activates the fan. This
means that there is probably some compute-bound process that isn't
terminating or is taking a long time to find a solution, with each step
requiring lots of work. An example of this is the Collatz program shown
in class. 

To diagnose this problem, we want to see a list of processes that are
running and see which one has the highest CPU utilization. This can be
done by running 'top -o cpu' in the Terminal if he is using a Unix-based
system (such as Linux or OS X). 

The solution depends on what process we suspect is causing the processor
to constantly be working. If it is something like a virus scanner
performing a routine sweep, we can change the time it is scheduled to
run to some time when he isn't using the computer. If it is a browser,
it can be a process such as Flash which through some bug is constantly
computing some sort of data. 

As a side note, running 'top -o cpu' for a long time caused the fan to
start spinning fast since it is always computing which is the process
utilizing the most CPU resources._ (Chris McFarland)

>_Assumptions: Computer fan vent is clear of debris such as dust
 buildup.
First, I would explain to my uncle the probable causes as follows:
"The reason a computer fan runs is to cool down the processor and other
 contents of a laptop and maintain them with a range of operating
 temperatures to protect the components. The components within a
 computer heat up due to being used by the operating system on the
 computer and the programs being run on that operating system; in a
 laptop, this applies more to the processor than any other
 components. Thus, on a laptop, the fan is almost exclusively for
 cooling the processor. The processor heats up due to use by programs
 and the OS on your machine, from that we can deduce that there is some
 process being run either by the operating system or a program that is
 doing a lot of work on the processor, causing it to heat up and thus
 causing the fan to run loudly."

Second, I would diagnose the problem:
The quickest way to diagnose the problem is to open up a program such as
task manager, or top in linux. This allows me to see which processes are
running and what percentage of the CPU time they are using, letting me
quickly sift through and find the process(es) consistently using the
most CPU time. If the problem is being caused by process, that process
will show up here. The second part of the diagnosis is to figure out why
the process is taking up so much CPU time and determine if it is
benevolent and, if it is, whether or not it is a critical
process. Determining why it is taking up so much time is important
because it is necessary to know if the behavior is normal for the
program or if it is buggy and is stuck in an infinite loop or something
similar. If it is not buggy, we then need to decide if it is benevlolent
by researching it on the internet. If it is, then we need to see if it
is a critical process or not. Finally, we should also try and figure out
if this behavior is temporary, constant, or simply periodic, such as
with an anti-virus scanner.

Third, I would suggest a solution to my uncle:
The solutions proposed are dependent on the characterisitcs determined
in the diagnosis. If the process is buggy, I would ask my uncle if the
program associated with it is necessary or wanted on his computer. If it
is not, I would suggest it be removed. If the process is not buggy, I
would determine if it is benevolent or not, suggesting to my uncle that
it be removed immediately if it is not benevolent. If it is benevolent,
I would try and figure out if it is a critical process, and if it is
not, I would try killing the process manually and letting it restart
itself to see if the behavior is fixed. If it is critical to a program,
and the behavior is expected, and the behavior is not temporary or
periodic, I would suggest to my uncle that he find a replacement program
that perhaps is less resource intensive than the one currently being
used._ (Kelvin Green)

>_I would attempt to take his computer from him and hand him a nice
 safe, fanless ipad explaining that there are some levels of detail not
 worth getting into. If my uncle is bigger than me then I would explain
 to him that he shouldn't be browsing the web using internet
 explorer. Not only does he probably have a virus because he does not
 know what a spam filter is, but the 27 tabs of youtuber renditions of
 Gangam style he has been trying to show me are spending so much time
 processing that his CPU is getting hot. Frankly I would just try to
 turn off his computer, but because he hasn't turned it off since the
 last power outage there are going to be about 60 microsoft word
 documents that must be saved. At this point, Thanksgiving dinner is
 ready and the best thing I can do is tell him to ask santa for a
 Mac. But because I have taken CS4414 and reread the question, I would
 in a moment of clarity tell him he should just try closing some of
 programs he is not using, which would free up some memory (because his
 system is probably reading pages from disk) and reduce the burden on
 the processor._ (Nick Skelsey)


> _Yes and no, I think that while we definitely
learn alot about OS/Rust in the classroom, most of my learning
experiences have come from the rust IRC and documentation and there
arent too many questions (if at all) on this exam that cover that kind
of learning outside the classroom._

The problem sets are mostly about these things, and the midterm is
intended to check students are getting things that are not easily
covered in the problem sets.  (and its great that you are learning a lot
from the #rust IRC).

_Not completely. Was somewhat hoping for more coding problems,
mapreduce/list problems, etc._

You'll have plenty of opportunity for programming in the problem sets
and project.  


Do you have any other comments about the exam, the course so far, or
what you hope for the rest of the semester?

> _I hope to go into more implementation details, since I think
understanding lower-level design decisions help me reason about the high
level goals of the system_

> _I'm fairly intimidated by PS3, and while I do see the interesting
  learning opportunities it presents, I think taking a class or two with
  some How-To's might be of benefit to the class._

Hopefully things are becoming more clear after the last class, but I'm
happy to cover specific things if people make requests.

> _I hope the final is as relaxing as this exam._

If all goes well, you should find the final even more relaxing!  

> _I wish the course focused more on operating systems and less on
  Rust.  While I believe Rust has useful features and I know that
  struggling through poorly documented systems is a valuable skill to
  learn, I really wanted to go more in depth and focus on operating
  systems in this course._

I think this is true if you focus on the time you spend doing the
assignments, but very little of the time I spend in class is focused on
Rust or Rust-specific.  I do understand the comment about wanting to get
more in-depth in how operating systems kernels work at a low level, and
we'll do that soon.



https://github.com/rtm9zc/RustDeadlock/blob/master/deadlock.rs
Robert Michaels

 
