subject

At this point xv6 has no concept of users or groups. You will begin to add this feature to xv6 by adding a uid and gidfield to the process structure, where you will track process ownership. These will be of type unsigned int since negative UIDs and GIDs make no sense in this context. Note that when these values are passed into the kernel, they will be taken off the stack as "int"s. There is no issue with this as you will convert them to unsigned ints immediately. It is, however, critical, that the function prototypes in user. h declare values as unsigned as you will see below.
The ppid is the "parent process identifier" or parent PID. The proc structure does not need a ppid field as the parent can, and should, be determined on-the-fly. Look carefully at the existing proc structure in proc. h to see what is needed.
Note: that the init process is a special case as it has no parent. Your code must account for any process whose parent pointer is NULL. For any such pointer, you will display the PPID to be the same as the process PID. Do not modify a parent pointer that is set to NULL; leave it that way as it becomes important in a later project.
You will need to add the following system calls:
uint getuid( void ) // UID of the current process
uint getgid( void ) // GID of the current process
uint getppid( void ) // PPID of the current process
int setuid ( uint ) // set UID
int setgid ( uint ) // set GID
Your kernel code cannot assume that arguments passed into the kernel are valid and so your kernel code must check the values for the correct range. The uid and gid fields in the process structure may only take on values 0 <= value <= 32767. You are required to provide tests that show this bound being enforced by the kernel-side implementation of the system calls.
The following code is a starting point for writing a test program that demonstrates the correct functioning of your new system calls. This example is missing several important tests and fails to check return codes, which is very bad programming. You should fix the shortcomings of this code or write a new test program that properly demonstrates correct functionality for all test cases.
int main ( void )
{
uint uid, gid, ppid;
uid = getuid();
printf( 2 , " Current UID is: %d\n", uid );
printf( 2 , " Setting UID to 100\ n" );
setuid (100);
uid = getuid ();
printf( 2 , " Current UID is: %d\n", uid );
gid = getgid() ;
printf( 2 , " Current GID is: %d\n", gid );
printf( 2 , " Setting GID to 100\ n" );
setuid (100);
gid = getgid();
printf( 2 , " Current GID is: %d\n", gid );
ppid = getppid();
printf( 2 , "My parent process is: %d\n", ppid );
printf( 2 , "Done!\n" );
exit();
}

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 11:40
Pthreads programming: create and terminate a thread write a c++ program that creates a thread. the main will display a message “hello world from the main”. the main will create a thread that will display a message “hello world from the thread” and then terminates with a call to pthread_exit()
Answers: 3
question
Computers and Technology, 24.06.2019 09:30
Retype the statements, correcting the syntax errors. system.out.println("num: " + songnum); system.out.println(int songnum); system.out.println(songnum " songs"); note: these activities may test code with different test values. this activity will perform two tests: the first with songnum = 5, the second with songnum = 9. see how to use zybooks.
Answers: 1
question
Computers and Technology, 24.06.2019 16:00
To fill (copy) a cell across or down, point to the of the cell and drag. top left corner top right corner bottom left corner bottom right corner
Answers: 3
question
Computers and Technology, 24.06.2019 17:50
Create a class hand in its own module. one object of class hand represents a hand of cards and so one object stores a number of card objects. for this assignment you will submit three separate modules, one with the definition of class card, one with the definition of class hand and one with the main application that thoroughly tests class hand.class hand must contain the following four methods: 1) , numcardsinhand) takes an integer as parameter and initializes a hand object with numcardsinhand card objects inside it. these card objects are generated randomly. for simplicity, assume an infinite number of decks of cards.2) bjvalue(self) returns the blackjack value for the whole hand of cards3) ) returns a string containing all the cards in the hand4) hitme(self) adds one randomly generated card to the handcreate a main program in its own module that thoroughly tests class hand. you will have three modules/files to upload to your etudes assignment submission: card.py, hand.py and the module that contains your main program.two alternatives for extra credit - you cannot get credit for both! (+1 point): after you have thoroughly tested the class hand and all of its methods, add code to your main program that stores one hand object as a pickle file and reads it back into a new hand object. you are only eligible for this extra credit if class hand has all four of the methods above working.or(+2 points): after you have thoroughly tested the class hand and all of its methods, add code to your main program that stores one hand object as a text file on the disk and reads it back into a new hand object. you are only eligible for this extra credit if class hand has all four of the methods above working.notes: -start by making any and all modifications suggested by my comments to your previous submission of class card from assignment #6 "a robust card object"-once your class card is tested and working well, you will not make any further modifications to it for the purposes of class hand.-you can keep the test code for class card intact. if it is indented inside an if __name__ == "__main__", then it will not be executed when your main program's module imports it.-to save time, write and test one method for class hand at a time.-under no circumstances are you to attempt the extra credit until you are completely finished with writing and testing all the methods in class hand.
Answers: 3
You know the right answer?
At this point xv6 has no concept of users or groups. You will begin to add this feature to xv6 by ad...
Questions
question
Mathematics, 11.01.2020 05:31