bullfoki.blogg.se

Pintos project2
Pintos project2









pintos project2

If any of the call fails due to reasons such as invalid file descriptor, we should exit the user process. After that, we should retrieve the arguments from argv, call the corresponding file operation functions according to the input system call number. If not valid, we simply exit the user process.Īfter validating the arguments, we will have to obtain the global lock filesys_lock so that no multiple filesystem functions are called concurrently.

pintos project2

The above process is part of implementation inside add_file and remove_file.īefore any file operation call through the syscall_handler, we will have to call validate_addr() (implemented in task2) to validate the input argument address. 1024 should be far more enough than the file descriptors we will possibly need. When we finish using the fd number, we set arr back to 0. Then to find a usable fd to allocate, we simply iterate through the array until we find an empty spot, i.e. We initialize the array to be all zero, except for arr and arr having 1 because they are reserved for STDIN_FILENO and STDOUT_FILENO. We use int field 1 to indicate the corresponding index is already used as an fd, and 0 meaning not being used.

pintos project2

Bool load ( const char *file_name, void (**eip) ( void), void **esp) įile descriptor management: To correctly allocate and deallocate the file descriptor, for each process, we use an int array of length 1024 to record available file descriptor numbers to allocate.











Pintos project2