RSS


[ Pobierz całość w formacie PDF ]
.These programs are known as setuidprograms and they are useful because it is a way of restricting accesses toservices, particularly those that run on behalf of someone else, for example anetwork daemon.The e ective uid and gid are those from the setuid programand the uid and gid remain as they were.The kernel checks the e ective uidand gid whenever it checks for privilege rights. gle system uid and gid These are normally the same as the e ective uid and gidand are used when checking le system access rights.They are needed for NFSmounted lesystems where the user mode NFS server needs to access les as ifit were a particular process.In this case only the le system uid and gid arechanged not the e ective uid and gid.This avoids a situation where malicioususers could send a kill signal to the NFS server.Kill signals are delivered toprocesses with a particular e ective uid and gid.saved uid and gid These are mandated by the POSIX standard and are used byprograms which change the processes uid and gid via system calls.They areused to save the real uid and gid during the time that the original uid and gidhave been changed.4.3 SchedulingAll processes run partially in user mode and partially in system mode.How thesemodes are supported by the underlying hardware di ers but generally there is asecure mechanism for getting from user mode into system mode and back again.User mode has far less privileges than system mode.Each time a process makes asystem call it swaps from user mode to system mode and continues executing.Atthis point the kernel is executing on behalf of the process.In Linux, processes donot preempt the current, running process, they cannot stop it from running so thatthey can run.Each process decides to relinquish the CPU that it is running on whenit has to wait for some system event.For example, a process may have to wait fora character to be read from a le.This waiting happens within the system call, insystem mode; the process used a library function to open and read the le and it,in turn made system calls to read bytes from the open le.In this case the waitingprocess will be suspended and another, more deserving process will be chosen to run.Processes are always making system calls and so may often need to wait.Even so, ifa process executes until it waits then it still might use a disproportionate amount ofCPU time and so Linux uses pre-emptive scheduling.In this scheme, each process isallowed to run for a small amount of time, 200ms, and, when this time has expiredanother process is selected to run and the original process is made to wait for a littlewhile until it can run again.This small amount of time is known as a time-slice.It is the scheduler that must select the most deserving process to run out of all ofSee schedulethe runnable processes in the system.A runnable process is one which is waiting inkernel sched.conly for a CPU to run on.Linux uses a reasonably simple priority based schedulingalgorithm to choose between the current processes in the system.When it has chosena new process to run it saves the state of the current process, the processor speci cregisters and other context being saved in the processes task struct data structure.It then restores the state of the new process again this is processor speci c to runand gives control of the system to that process.For the scheduler to fairly allocateCPU time between the runnable processes in the system it keeps information in thetask struct for each process:policy This is the scheduling policy that will be applied to this process.There aretwo types of Linux process, normal and real time.Real time processes have ahigher priority than all of the other processes.If there is a real time processready to run, it will always run rst.Real time processes may have two types pof policy, round robin and rst in rst out.In round robin scheduling, eachrunnable real time process is run in turn and in rst in, rst out schedulingeach runnable process is run in the order that it is in on the run queue andthat order is never changed.priority This is the priority that the scheduler will give to this process.It is also theamount of time in jiffies that this process will run for when it is allowedto run.You can alter the priority of a process by means of system calls andthe renice command.rt priority Linux supports real time processes and these are scheduled to have ahigher priority than all of the other non-real time processes in system.Thiseld allows the scheduler to give each real time process a relative priority.Thepriority of a real time processes can be altered using system calls.counter This is the amount of time in jiffies that this process is allowed to runfor.It is set to priority when the process is rst run and is decremented eachclock tick.The scheduler is run from several places within the kernel.It is run after putting thecurrent process onto a wait queue and it may also be run at the end of a system call,just before a process is returned to process mode from system mode.One reason thatit might need to run is because the system timer has just set the current processesSee schedulein counter to zero.Each time the scheduler is run it does the following:kernel sched.ckernel work The scheduler runs the bottom half handlers and processes the sched-uler task queue.These lightweight kernel threads are described in detail inchapter 11.Current process The current process must be processed before another processcan be selected to run.If the scheduling policy of the current processes is round robin then it is putonto the back of the run queue.If the task is INTERRUPTIBLE and it has received a signal since the last time itwas scheduled then its state becomes RUNNING.If the current process has timed out, then its state becomes RUNNING.If the current process is RUNNING then it will remain in that state.Processes that were neither RUNNING nor INTERRUPTIBLE are removed from therun queue.This means that they will not be considered for running when thescheduler looks for the most deserving process to run.Process selection The scheduler looks through the processes on the run queuelooking for the most deserving process to run.If there are any real time pro-cesses those with a real time scheduling policy then those will get a higherweighting than ordinary processes.The weight for a normal process is itscounter but for a real time process it is counter plus 1000.This means that ifthere are any runnable real time processes in the system then these will alwaysbe run before any normal runnable processes.The current process, which hasconsumed some of its time-slice its counter has been decremented is at a dis-advantage if there are other processes with equal priority in the system; thatis as it should be.If several processes have the same priority, the one nearest gthe front of the run queue is chosen.The current process will get put onto theback of the run queue.In a balanced system with many processes of the samepriority, each one will run in turn.This is known as Round Robin scheduling.However, as processes wait for resources, their run order tends to get movedaround.Swap processes If the most deserving process to run is not the current process,then the current process must be suspended and the new one made to run.When a process is running it is using the registers and physical memory of theCPU and of the system.Each time it calls a routine it passes its argumentsin registers and may stack saved values such as the address to return to in thecalling routine.So, when the scheduler is running it is running in the contextof the current process.It will be in a privileged mode, kernel mode, but itis still the current process that is running [ Pobierz całość w formacie PDF ]
  • zanotowane.pl
  • doc.pisz.pl
  • pdf.pisz.pl
  • nvs.xlx.pl