Processes
CS 321 2007 Lecture, Dr. Lawlor
Finish talking about syscalls, give some examples. Announce syscall homework due Friday.
The textbook actually describes the basics of processes better than I
can here. A process is basically one execution of a
program/application.
A process boils down to:
- CPU Registers (including the stack pointer)
- Memory. This is actually an entirely separate address space on modern machines, but was once just a range.
- A whole lotta OS book-keeping stuff:
- The user that owns the process
- The list of stuff the process is allowed to do: (see setrlimit for UNIX)
- Which files the process can access (usually a function of the user)
- Which files are open and accessible
- Create new processes
- Allocate new memory
- How long the process has been running, and other book-keeping information.
- Whether the process is ready to run again (or if it's stopped, for example, waiting for I/O).
- "Environment variables"--see getenv. The most popular environment variable is PATH, which lists the directories that can contain command-line routines.
In Linux, there's one struct, the "task_struct", that contains everything a process needs. task_struct is in /usr/include/linux/sched.h.
You create new processes with CreateProcess / CreateProcessAsUser (Windows) or fork (UNIX).