CS 111 Operating SystemsScribe Notes for Winter 2012 Lecture 4By Vahe Musinyan & Arman AbrahamyanHARD MODULARITYHow to implement hard modularity?
|
Pros:+ Hard modularity: client and server are protected from each other |
Cons:- Slow (latency between modules) |
We want to create a "virtual machine" to run our untrusted codes there. In this case we can have one real machine that creates two
virtual machines. All disasters will happen in virtual machine and the real machine will not suffer from errors or other problems.
Pros:+ Gives hard modularity |
Cons:- Wayyyyy too slow |
OTERWISE - run at full speed (emulator will run at a speed of Real machine).
This whole process is called "virtualizable process".
If you have more than 6 arguments for function, that means something is "wrong". Try to minimize it up to 6.
Write function implementation (runs on Virtual Machine)
ssize_t
write (int fol, char *buf, size_t bufsize);
{ ….
Asm ("int 128");
… }
Virtualization is only one-way protection
But faster than client/server on a typical hardware
OS organization
In some cases we do not need to copy all registers, for example n = getpid().
Protecting memory is hard, for now we will skip this. This will be done later in the course.
Ways for applications to create/destroy processes
To destroy:
1) a process can issue a privileged instruction "halt"
2) exit (23); // the number in exit () shows the status (8 bit code)
To create:
1) p = fork (); // clones the current process
except:
p = child's pid in parent
p = 0 in child
p = -1, if ERROR