Re:Process management
Posted: Wed Feb 26, 2003 8:18 am
Hello!
To Pype.Clicker and Perica Senjak:
It's much simpler. There is no need for the shifting. The processor first look at Bits 0 and 1 to see the prevelege level. Is this OK the processor looks at Bit 2. This is the table indicator. If it is set the descriptor will be found in the Local Descriptor Table. Otherwise it is in the Global Descriptor Table.
The the processor reads the whole 16 Bits bit ignores Bits 0,1 and 2 (he threats them like thy were zeroed). This read 16 Bits are the byte-offset in the GDT.
Of course the result is the same like these shifting but it is simpler. Just ignore Bits 0, 1, 2 and you have the byte-offset.
As it seems there are a lot of fans of stack task switching here. I want to mention the main problem with stack task switching: The scheduler uses the user stack and there for it might be possible that a stack overflow occur while task switching. This would cause this one task to crash.
Even worse would it be if there were no room in the data segment (I assume that the data and stack segment are both together). Consider of a very simple program which has no need for a stack. Thus the value of esp can be 0. This would lead to a General Protection Fault if a timmer interrupt occur.
There is also a problem of security: If a task get control again everything seems like before. But there ws a change: If you consider of a esp-value of 488 the eip-adress can be found at address 484 and all the register values are still in memory. This information is nothing new for the process because the process is allowed to know its own register values. But if the scheduler is doing something non-normal like copying values from one process to another or dealing with information that should only be known be the kernel the process can get these information out of the stack (or better to say: the memory where the stack was while scheduling).
Because of all these problems Intel (the idea is much older) introduces the TSS. With this structure user processes and the scheduler are seperated.
There are a lot of methods dealing with the problems that might happen with stack task switching but keep in mind that a user program might do something unusual (like setting esp to zero) or the user program might have access to secret information.
To Pype.Clicker and Perica Senjak:
It's much simpler. There is no need for the shifting. The processor first look at Bits 0 and 1 to see the prevelege level. Is this OK the processor looks at Bit 2. This is the table indicator. If it is set the descriptor will be found in the Local Descriptor Table. Otherwise it is in the Global Descriptor Table.
The the processor reads the whole 16 Bits bit ignores Bits 0,1 and 2 (he threats them like thy were zeroed). This read 16 Bits are the byte-offset in the GDT.
Of course the result is the same like these shifting but it is simpler. Just ignore Bits 0, 1, 2 and you have the byte-offset.
As it seems there are a lot of fans of stack task switching here. I want to mention the main problem with stack task switching: The scheduler uses the user stack and there for it might be possible that a stack overflow occur while task switching. This would cause this one task to crash.
Even worse would it be if there were no room in the data segment (I assume that the data and stack segment are both together). Consider of a very simple program which has no need for a stack. Thus the value of esp can be 0. This would lead to a General Protection Fault if a timmer interrupt occur.
There is also a problem of security: If a task get control again everything seems like before. But there ws a change: If you consider of a esp-value of 488 the eip-adress can be found at address 484 and all the register values are still in memory. This information is nothing new for the process because the process is allowed to know its own register values. But if the scheduler is doing something non-normal like copying values from one process to another or dealing with information that should only be known be the kernel the process can get these information out of the stack (or better to say: the memory where the stack was while scheduling).
Because of all these problems Intel (the idea is much older) introduces the TSS. With this structure user processes and the scheduler are seperated.
There are a lot of methods dealing with the problems that might happen with stack task switching but keep in mind that a user program might do something unusual (like setting esp to zero) or the user program might have access to secret information.