Multi User Expansion
Multi-user Extension
Two special users root and kernel are already initialised in the user table..
The shell will run in the context of the logged in user.
Login Interrupt
Set the MODE_FLAG in the process table entry to 27,
indicating that the process is in the login system call.
//Switch to the Kernel Stack. see kernel stack management during system calls
Save the value of SP to the USER SP field in the Process Table entry of the process.
Set the value of SP to the beginning of User Area Page.
If PID of the current process is not 1, return -2. /* Login process has PID = 1 */
Get the User Table entry curresponding to the username.
If an entry does not exist, return -1.
Use the ecrypt statement to encrypt the password supplied as input.
If the encypted input password does not match the ENCRYPTED PASSWORD field in the user table entry, return -1.
In the process table entry for the shell process, set STATE as CREATED and USERID as that of the user who is logging in.
Set the state of the current process in it's process table entry as (WAIT_PROCESS, 2) /* Login waits for shell to exit */
In system status table, set the CURRENT_USER_ID as that of the user who is logging in.
Invoke the context_switch() function in the Scheduler Module.
Reset the MODE_FLAG and restore SP to user stack.
ireturn;
Logout Interrupt
Set the MODE_FLAG in the process table entry to 28,
indicating that the process is in the logout system call.
//Switch to the Kernel Stack. see kernel stack management during system calls
Save the value of SP to the USER SP field in the Process Table entry of the process.
Set the value of SP to the beginning of User Area Page.
If the current process is not the shell, return -1. /* Shell process has the PID 2 */
Kill all user processes except the shell by calling the kill_all() function in the Process Manager module.
Set the STATE of the current process(shell) in the process table to TERMINATED.
/* Shell should be set ready to run when the next user logs in. */
Obtain the entry point IP value from the header of the shell program. Place it in the beginning (logical addesss 4096)
of the stack of the shell(current process). Reset the USERSP field of the shell to 4096.
Wake up the Login process by changing STATE in it's process table entry to READY.
In system status table, reset the CURRENT_USER_ID field back to 0 (kernel).
Invoke the context_switch() function in the Scheduler Module.
Why don't we kill the current process (shell) by using the exit_process() module function?
Availability of instructions
- While removing user, check if there are files such that he is the owner
Why Newusr , Remusr and Setpwd system calls are permitted to execute only from shell program whereas Getuid and Getuname can be executed from any application program?
The system calls Newusr , Remusr and Setpwd modify the data related to users in the user table. Getuid and Getuname system calls only access data related to users. As application programs other than Shell are not allowed to modify the user related data, system calls Newusr , Remusr , Setpwd are only executed from shell process.