The GDT (Global Descriptor Table), LDTs (Local Descriptor Tables) and the IDT (Interrupt Descriptor Table) , all located in memory provide protected access to system resources. The GDT and IDT are pointed to by special registers within the CPU (so the processor can access them), and the GDT entries point both to the operating system segments and to the LDTs. The IDT contains pointers to code that needs to be executed when interrupts occur.
Each running program has its own LDT but there is a single GDT for the entire system.
The LDT describes segments local to each program including its text (code), data, stack and so on. The GDT describes system segments including the operating system itself. (Segments are independent address spaces. Segmentation is one of the techniques use to manage memory on computers. More on segments when we discuss memory management but for now just understand that with segmented memory, we need a two part address to reach any memory location - the first part is the address of the segment and the second part is the location (offset) within the segment.)
So the GDT basically points to (i.e. contains the physical addresses of) segments that contain the operating system code and data but also provides a way to get to all the LDTs in the system.
Friday, October 15, 2010
Sunday, October 3, 2010
Saturday, October 2, 2010
Wednesday, September 29, 2010
Privilege Levels
The architecture of 32-bit Intel processors provides four privilege levels of which Minix takes advantage of three. These are defined as C macros in kernel/protect.h
#define INTR_PRIVILEGE 0 /* kernel and interrupt handlers */
#define TASK_PRIVILEGE 1 /* kernel tasks */
#define USER_PRIVILEGE 3 /* servers and user processes */
The kernel contains code that runs during interrupts and during context switches, so it always runs with INTR_PRIVILEGE. Every address in memory and every register in the CPU can be accessed by a process with this privilege level.
The System and Clock tasks run with the TASK_PRIVILEGE level which allows them to access I/O but not to use instructions that modify special registers (like those that point to descriptor tables).
Servers and user processes run at USER_PRIVILEGE level. Such processes are unable to execute certain instructions such as those that access I/O ports, change memory assignments or change privilege levels themselves.
Note that of the four layers of processes in the Minix OS, all the layers except Layer 1 run with USER_PRIVILEGE level (i.e. user mode).
#define INTR_PRIVILEGE 0 /* kernel and interrupt handlers */
#define TASK_PRIVILEGE 1 /* kernel tasks */
#define USER_PRIVILEGE 3 /* servers and user processes */
The kernel contains code that runs during interrupts and during context switches, so it always runs with INTR_PRIVILEGE. Every address in memory and every register in the CPU can be accessed by a process with this privilege level.
The System and Clock tasks run with the TASK_PRIVILEGE level which allows them to access I/O but not to use instructions that modify special registers (like those that point to descriptor tables).
Servers and user processes run at USER_PRIVILEGE level. Such processes are unable to execute certain instructions such as those that access I/O ports, change memory assignments or change privilege levels themselves.
Note that of the four layers of processes in the Minix OS, all the layers except Layer 1 run with USER_PRIVILEGE level (i.e. user mode).
Tuesday, September 28, 2010
Fork
Just for the heck of it, I added some print statements to the code in forkexit.c in the Minix source. After recompiling, linking, creating a boot image and installing in the boot directory when I restarted the machine, all I could see was thousands and thousands of those messages I had introduced. After startup, no matter what I did the screen was littered with those messages. Which is natural since fork happens (one or more times) whenever you execute a command.
Monday, September 27, 2010
Subscribe to:
Posts (Atom)




