- The Process is a unit of organization on a coputer. Each process
is a distinct actively running embodiment of a program.
- Made up of program code, data, and properties.
- These properties are:
- Identifier- id number
- State - running or not, see below
- Priority
- Program Counter
- Memory Pointers - pointers to program and data, and shared
memory.
- Context data - what's in the registers.
- I/O status
- Accounting information - time on processor, etc.
- These properties are explicitly stored in the OS and together
are called the Process control block.
- Running States
- Processes can be in a number of "states". The two most
obvious are running, and not running.
- When is a process not running? When some other process is
running.
- When does a process get to run? When the running process is
done, or when the running process's time has expired. (This
is how we simulate parallelism in a single processor- change
the running process frequently)
- How does the CPU switch to the new process? That's the job
for the dispatcher
- Dispatcher
- Dispatcher starts with a clock or timer interrupt.
- On PCs these are generated by programmable timers that write
to a special register (instead of by the system clock, which
really happen too frequently).
- with each "tick" of the timer, it increments the value until
it reaches some programmed value, and then the interrupt is
signalled.
- The interrupt handler must first reset the timer, then save
the registers (including the PC) of the currently running
process to the PCB, load up the registers of next processes,
and finally, set the PC.
- Example.


(note that processes can be switch for timeout, where they go back
on the ready queue, or by I/O blocking, where they go on the
blocked queue)
- So how does the dispatcher know what process to run next? Well,
typically, it will have a queue of all processes that are ready to
run but not running. This is called the ready queue. The
dispatcher enqueues the old process, and dequeues the new one from
the head.
- Process creation and termination.
- Processes are created (spawned) by other processes. In unix
this is called a fork().
- the new process is called the child process, and the old is
the parent.
- How does this work? Well...
- the call to fork() is a system call. The first part of
it is just a function call to a library. The parent
process is still running.
- The function does a little set up and then it generates
a software interrupt.
- The CPU is set to kernel mode.
- The handler sees that it was a fork, and starts to
process it. (calls do_fork()).
- the function makes a copy of the parent: allocate the
memory, copy program and data, create new PCB, copy the
PCB, add the child to the ready queue, reseut CPU to user
mode, and return.
- Recall that exec() is what makes the process a new
program.
- Processes end because they ask to (exit()), there was an
error, or they get a signal.
- depending on how it is initiated, the beginning of
termination can be different, but eventually, like fork, the
system will run do_exit(), which frees all the memory, deletes
the PCB, and calls the dispatcher to see who runs next.
- Five state model.
- Multiple blocked queues.
- Suspended processes, swapping.
- Sometimes we will want to have more processes going than we
have room for in main memory.
- One thing we can do is use virtual memory, where some
processes are not in RAM but on disk.
- When the system goes to add a new process that doesn't fit
in RAM, the memory is allocated, but on disk, not RAM. It is
still added to the ready queue.
- If the dispatcher ever tries to run a process that is on
disk, it swaps that process with one that is already in RAM.
Copy the one process to disk, deallocate its memory, and copy
the one from disk into RAM
- There are many strategy on what to pick, but one obvious
one is to select a process that is blocked.
- This gives us more states a process can be in.
- Note we can also suspend a process directly, either from
another process or from the user.
- Organization of the kernel.
- Three basic models:
- The first is the easiest to conceptualize, everything
happens in the kernel. Very hard to debug because modularity
breaks down.
- Next model, we link SOME OS functions into the processes
themselves. That way, some OS functions don't require a
switch to the kernel. (even keep the PCB in the process
itself).
- 3- clean and modular. Slower.
- Security.
- For security in OS, we will look at many issues. With
respect to processes, it has mostly to do with obtaining a
process that executes with root access.
- Intruders.
- Masquerader - uses a legitimate users account
- Misfeasor - legitimate user who accesses data they
shouldn't
- Clandestine - escalates to root privileges.
- Software/malware
- trojans and viruses.
- backdoors and logic bombs.
- Countermeasures
- Intrusion Detection Systems
- Host-based, monitor system activity
- Network-based, monitor network packets.
- Authentication
- Something the person knows
- Something the person possesses
- Something the person is
- Something the person does (dynamic biometrics)
- Access Control
- Firewalls