A multithreaded simulation of the process switching mechanism in operating systems. This was my project in "CSC 340: Operating Systems" course at Ahmedabad University.
A custom instruction set was used for simulation which consisted of some simple operations. The context of the processes consists of the value of variables which are saved in the 'variables.txt' file. This allows the processes to resume from last instruction executed with value of variables intact.
1. opcode.txt - Each line contains the operation code and its integer representation separated by a space.
2. variables.txt - Each line contains the name of the variable and its current value.
3. processes/filein_(1/2/3/4/5).txt - Each file contains instructions and this file denotes a process.
Each process contains a set of instructions with the format as: opcode operand1 operand2 result_variable
Based on the option chosen by you during the execution of "launchMain.c", logs will be stored in in 2 different files.
- Implementation with threads -> logs_rr_with_thread
- Implementation without threads -> logs_rr_without_thread
- Run
gcc -pthread -o "executable_name" launchMain.c
- Run
./"executable_name"
Note: Recent execution of the code has revealed some peculiarities. The code runs on Ubuntu 16.04 but not on Ubuntu 18.04. Based on a preliminary search, it seems that this is caused due to the gcc compatibility issue with Ubuntu 18.04, primarily because of some changes in the 'newlib' library. You can read more about the bug here: Github issues | Launchpad Bug page
For more information about the project, please refer to the document 'OS_Project_Context_Switching.pdf'.