Skip to content

vrii14/xv6-Kernel-Threads

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

xv6-Kernel-Threads

This project is an implementation of Kernel Threads in xv6 Operating System.
It is built based on the guidelines of this repository. Userland threading library is also added with one-to-one mapping and synchronization with ticket-locks.
Appropriate system calls added for the implementation of threads and modified current system calls.

Team Members:

1. Vrinda Ahuja
2. Mrunal Kotkar

Added System Calls:

CLONE:

int clone(void(*fcn)(void *, void *), void *stack, int flags, void *arg1, void *arg2);
  • Clone system call to create a thread of a process and is called from wrapper function of userland threading library
  • fcn - Function pointer which runs in the created thread.
  • flags - Flags for the clone system call.
  • stack - Child stack to pass the function(fcn) arguments.
  • arg1 & arg2 - Arguments to function fcn.

JOIN:

int join(int threadId);  
  • Join system call to wait for execution of current thread and block the other threads and finally free thread resources after execution.
  • threadId - thread Id of the executing thread.

GETTID:

int gettid();
  • gettid system call to get the thread Id of currently executing thread

TGKILL:

int tgkill(int tgid, int tid, int sig);
  • tgkill system call to kill the thread from thread group with thread group id as tgid and thread id as tid.
  • tgid - thread group id (parent id)
  • tid - thread id to be killed
  • sig - signal number to be sent

Modified System Calls:

FORK:

  • Setting up tgid for the process.
  • Setting some other fields added to proc structure for implementation of threads.

EXIT:

  • Changing one condition in closing all file descriptors if it is a thread and CLONE_FILE flag is set.

KILL:

  • Adding condition for killing a parent process if it has child threads, kill all threads with tgkill.

Userland Threading Library:

Functions implemented for userland threading library are:

  • thread_create - Malloc the stack for thread and then calls clone system call.
  • thread_join - Free the stack for the thread and call join system call.
  • tlock_acquire - Acquires a ticket lock
  • tlock_release - Reelease the ticket lock
  • tlock_init - Initialize the ticket lock

Testing Suite:

Added a testing code to test all the functionality of Kernel threads with different test cases.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published