Difference between revisions of "Operating Systems 2014F Lecture 3"

From Soma-notes
Jump to navigation Jump to search
(Created page with "Process API Highly orthogonal - not only one way of doing things. Concept of Symbolic links, vs. hard links in Unix. In windows, there are about 5 different versions of links...")
 
Line 18: Line 18:
   
   
  }
  }
Every call to fork returns two values. fork() always returns a process id and 0. After you call fork, you have two copies of your code running. What is in their memory? What files are open? - Exactly the same process, but you have two of them. That's why you always see a fork in a conditional, because you have 2 distinct processes running w/ exactly the same memory state, except for one difference:
if (pid=fork()) {
  // parent
} else {
  // child
}


execve(, , )
execve(, , )


specific use cases for using both individually, without having to call both of them.
specific use cases for using both individually, without having to call both of them.

Revision as of 08:48, 12 September 2014

Process API

Highly orthogonal - not only one way of doing things. Concept of Symbolic links, vs. hard links in Unix. In windows, there are about 5 different versions of links, and some of them work on some versions of windows. It's a complete mess.

They first introduced 1 api, that turned out to be bad w/ limited functionality. Evolution of windows - you look at their API and you get a mess.

ioctl - system call in unix / linux systems -an abomination - it doesnt' have well defined semantics - io control you give it the number of a device, and some arguments, and it varies from device to device as to what it does. In unix that is the exception. Most of the base stuff is clean. The people who worked at bell labs were smart, they created a system that they wanted to use for themselves.

In Unix, you don't call 1 call - you have 2 calls.

fork()

The classic structure of how to use fork:

if (fork()) {

} else {

}


Every call to fork returns two values. fork() always returns a process id and 0. After you call fork, you have two copies of your code running. What is in their memory? What files are open? - Exactly the same process, but you have two of them. That's why you always see a fork in a conditional, because you have 2 distinct processes running w/ exactly the same memory state, except for one difference:

if (pid=fork()) {
 // parent
} else {
 // child
}


execve(, , )

specific use cases for using both individually, without having to call both of them.