1. Homepage
  2. Programming
  3. CS3103 Operating Systems Project: Process Scheduler with Priority Scheduling Policy

CS3103 Operating Systems Project: Process Scheduler with Priority Scheduling Policy

Engage in a Conversation
HK CityUCS3103Operating SystemsProcess SchedulerPriority Scheduling PolicyQEMUCNamed PIPE

CS3103 Project (Option B) CourseNana.COM

Note: We highly recommend using the Ubuntu environment on your own machine. Please DO NOT use the gateway server. Compiling errors may occur when using other operating systems, such as macOS or Windows. CourseNana.COM

The topics to be covered in this project:
How to coordinate the execution of multiple processes with scheduling. How to achieve inter-process communication. CourseNana.COM

This project is based on a simple operating system kernel, basekernel, which is available on Github: https://github.com/ruoxianglee/basekernel. Basekernel is not a complete operating system, but it is a starting point for us to study and develop new operating system code. And this is raw low-level code, not a production system. Basekernel can boot an Intel PCcompatible virtual machine in 32-bit protected mode, with support for VESA framebuffer graphics, ATA hard disks, ATAPI optical devices, process management, memory protection, simple graphics, and basic filesystem. From there, it's your job to expand the system with other functionalities. The functionalities to be implemented for you includes: CourseNana.COM

  1. a)  a process scheduler with the priority scheduling policy. CourseNana.COM

  2. b)  inter-process communication with named pipe. CourseNana.COM

Introduction CourseNana.COM

1. Prepare environment
On your
Ubuntu OS, install QEMU virtual machine and dependent packages: CourseNana.COM

sudo apt-get update sudo apt-get install make sudo apt-get install gcc sudo apt-get install genisoimage sudo apt-get install qemu-system-x86 CourseNana.COM

QEMU (Quick Emulator) is an open-source virtualization software. It provides hardware emulation for a wide range of CPUs, including x86, ARM, PowerPC, and more, enabling you to run guest operating systems that are designed for different architectures. CourseNana.COM

2. Clone and build
Download the source code of basekernel and compile:
CourseNana.COM

git clone https://github.com/ruoxianglee/basekernel cd basekernel make CourseNana.COM

3. Launch basekernel in QEMU virtual machine qemu-system-i386 -cdrom basekernel.iso CourseNana.COM

If everything is OK, you will see the interface where you can interact with basekernel, just like Linux terminal. Follow basekernel/README.md, you can execute commands once you see the kernel shell prompt ("kshell>"). Try to take some actions and play with it. See kshell_execute() function in kernel/kshell.c for all supported commands, such as: automount, list, run, etc. Refer to https://github.com/dthain/basekernel/wiki for detailed introduction of basekernel (in cases CourseNana.COM

where the detailed explanations deviate from the actual code implementation, it is essential to prioritize the code implementation as the authoritative reference). CourseNana.COM

Problem 1: Process Scheduler with Priority Scheduling Policy CourseNana.COM

In this problem, you should implement the priority scheduling policy into basekernel for process scheduling. Please implement the priority scheduling policy into basekernel, which must comply with the following requirements: CourseNana.COM

  • Implement the priority scheduling policy into /kernel/process.c, and also declare the corresponding functions in /kernel/process.h. CourseNana.COM

  • The priority scheduling policy must schedule all processes created by the system call syscall_process_run(), which are put into the ready queue (i.e., ready_list in /kernel/process.c). CourseNana.COM

  • The priority of a process should be specified as an input argument by user-level program when invoking the system call syscall_process_run(). CourseNana.COM

  • The supported priority of a process can be 0, 1, 2, 3, 4, .... Smaller integer represents higher priority. CourseNana.COM

  • Implement 5 test programs into /user/process1.c, /user/process2.c, /user/process3.c, /user/process4.c, and /user/process5.c, with a priority 9, 7, 2, 1, and 5, respectively. CourseNana.COM

  • Each of the above 5 test programs should print its pid and priority once it is scheduled for execution and invoke the below runForSeconds() function to run for several seconds before exiting. CourseNana.COM

  • Implement a start-up program into /user/schedulertest.c to launch the above 5 test programs with the same order as their indexes. This program just serves as a start-up code for the above 5 test programs and doesn't create any process. The following is the high-level example about how to launch one of the test programs for your reference. CourseNana.COM

// invoked in test programsvoid runForSeconds(int seconds)
{
CourseNana.COM

    unsigned int startTime; // seconds
syscall_system_time(&startTime);
    unsigned int timeElapsed;
     do

{ CourseNana.COM

        syscall_system_time(&timeElapsed);
timeElapsed -= startTime;
    } while(timeElapsed < seconds); }
//start-up program
const char * exec = "bin/process1.exe";
 int argc;  const
char *argv[3];
argv[0] = exec;
argv[1] = argument1;
argv[2] = argument2;
int pfd = syscall_open_file(KNO_STDDIR,exec,0,0);
if(pfd>=0) {
    int pid = syscall_process_run(pfd, argc,
&argv);
if(pid > 0) {
        printf("started process %d\n", pid);
    } else {
        printf("couldn't run %s: %s\n",
argv[0],strerror(pid));

} CourseNana.COM

    syscall_object_close(pfd);
} else {
    printf("couldn't find %s: %s\n",
argv[0],strerror(pfd));
}

Hint: CourseNana.COM

Remember to modify user/Makefile for compiling your test program. CourseNana.COM

Supplementary Information: CourseNana.COM

The followings are some background information about process in basekernel, which has already been implemented, based on which you would figure out how to achieve the scheduler. CourseNana.COM

In generally, a process is an instance of an executing program. From the kernel’s point of view, a process consists of: (1) user-space memory containing program code, (2) the variables used by that code, and (3) a set of kernel data structures that maintain information about the process’s state (e.g. page tables, table of open files, process resource usage and limits...). CourseNana.COM

In basekernel, the process has five states: cradle, ready, running, blocked, grave. It is actually a struct data type, which contains a process id (pid) as well as a process parent id (ppid). (see /kernel/process.h) The pid is allocated by a next fit search through an array of 1024 available ids. This array also serves to allow easy lookup of processes by id. In basekernel, the first process of the system is created with the kernel-level function process_init() (see /kernel/main.c), which is the C initialization point of the kernel. Every newly created process with function sys_process_run() or sys_process_wrun() will be the child of the first process, and will be launched and be put into back of a ready queue (see process_launch()). Then, the processes in the ready queue will be scheduled with the First Come First Served policy for CPU execution. Please read the source code in /kernel/process.h and /kernel/process.c to better understand how the process is managed. CourseNana.COM

Problem 2: Named PIPEs
In this problem, you are going to implement the Named PIPE mechanism into basekernel, which should be used by the user-level programming with specific well-designed system calls. Please implement the Named PIPE into basekernel, which must comply with the following requirements: CourseNana.COM

Implement your Named PIPE in kernel/named_pipe.h and kernel/named_pipe.c files. Add a new system call for creating a new Named PIPE, named as syscall_make_named_pipe(const char *fname). The new file associated with the CourseNana.COM

Named PIPE is named by the file name pointed to by the input argument fname.
Add a new system call for opening a Named PIPE, named as syscall_open_named_pipe(const char * fname). The file associated with the Named CourseNana.COM

PIPE is specified by the file name pointed to by the input argument fname.
Implement two test programs separately into /user/sender.c and /user/receiver.c to evaluate the correctness of your Named PIPE. The sender program should open a Named PIPE and then write some characters to receiver program, while the receiver program creates the Named PIPE and read the characters from the sender program. The CourseNana.COM

followings are the high-level example of the test programs for your reference. CourseNana.COM

// receiver program //sender program

char * fname = "/path/to/file/filename"; int res = syscall_make_named_pipe(fname); int fd = syscall_open_named_pipe(fname); char buffer[20]; syscall_object_read(fd, buffer, 20); CourseNana.COM

char *fname = "/path/to/file/filename";
int fd = syscall_open_named_pipe(fname);
char buffer[] = "Hello World\n"; syscall_object_write(fd,buffer,strlen(buffer)); printf("%s\n", buffer); CourseNana.COM

Hints: CourseNana.COM

  • To implement the Named PIPE, you should call the APIs in /kernel/fs.h for file operation, such as fs_dirent_mkfile() for new file creation. CourseNana.COM

  • Remember to modify user/Makefile for compiling your test program. CourseNana.COM

  • Remember to add named pipe to the struct kobject in /kernel/kobject.h. CourseNana.COM

  • To add new system calls, please modify /include/library/syscalls.h, /library/syscalls.c, CourseNana.COM

    /include/kernel/syscall.h, and /kernel/syscall_handler.c. Refer to the implementation of the open PIPE system call syscall_open_pipe(). CourseNana.COM

    Supplementary Information: CourseNana.COM

    The followings are some background about PIPE, which has already been implemented in basekernel, based on which you would figure out how to achieve a Named PIPE. CourseNana.COM

    A PIPE is a byte stream (technically speaking, it is a buffer in kernel memory), which allows processes to exchange bytes. A PIPE has the following properties: CourseNana.COM

  • It is unidirectional. Data travels only in one direction through a PIPE. One end of the PIPE is used for writing, the other one for reading. CourseNana.COM

  • Data passes through the PIPE sequentially. Bytes are read from a PIPE in exactly the order they were written. CourseNana.COM

  • No concept of messages, or message boundaries. The process reading from a PIPE can read blocks of data of any size, regardless of the size of blocks written by the writing process. CourseNana.COM

  • Attempts to read from an empty PIPE blocks the reader until, either at least one byte has been written to the PIPE, or a no-terminating signal occurs. CourseNana.COM

  • If the write-end of a PIPE is closed, then a process reading from the PIPE will see endof- file once it has read all remaining data in the PIPE. CourseNana.COM

  • A write is blocked until, either sufficient space is available to complete the operation atomically#, or a no-terminating signal occurs. (#on Linux, pipe capacity is 65536 bytes.) CourseNana.COM

  • Writes of data blocks larger than PIPE_BUF* bytes may be broken into segments of arbitrary size (which may be smaller than PIPE_BUF bytes). (*on Linux, PIPE_BUF has the value 4096 bytes.) CourseNana.COM

    In basekernel source code, there is an implemented PIPE mechanism (see kernel/pipe.h and kernel/pipe.c) and also the associated user-level test program (see user/test/pipetest.c). You will see how the PIPE is used for reading and writing between two child processes. CourseNana.COM

    A Named PIPE (a.k.a, FIFO) is also a byte stream. Semantically, a Named PIPE is similar to a PIPE. The principal difference is that a Named PIPE has a name within the file system, and is opened and deleted in the same way as a regular file. This allows a Named PIPE to be used for communication between unrelated processes, as long as the processes have the file name. Just as with PIPEs, a Named PIPE has a write-end and a read-end, and data is read from the Named PIPE in the same order as it is written. CourseNana.COM

Grading CourseNana.COM

We will grade your work with the following three considerations:
Design (Project Report) 30% Implementation (Code) 30% Evaluation (Test Result) 40% CourseNana.COM

Design (30 %) CourseNana.COM

Your project report explaining your design details will account for 30% of your project grade. The project report should encompass the following content: CourseNana.COM

  1. a)  Abstract idea and mechanism design (15%). Please provide a detailed explanation of the abstract idea behind your mechanism design for both problems. Describe how you implemented the priority scheduling policy and the named pipe. You can utilize various methods to present your design, such as textual descriptions, flow diagrams, pseudo- code, or any other suitable means. CourseNana.COM

  2. b)  Implemented functions (15%). List and explain all the functions you have implemented for both problems. Ensure to include the input and output arguments for each function, as well as a clear description of their functionality. It is recommended to provide comprehensive coverage of all the relevant functions. CourseNana.COM

You could also discuss any difficulties encountered and the lessons learned in solving them. CourseNana.COM

In case your code cannot be compiled or does not give the correct result, you may still get part of the design scores according to the quality of your project report. CourseNana.COM

Implementation (30 %) CourseNana.COM

The implementation of your two programs will account for 30% of your project grade. Your code must be written by you own. The code should be nicely formatted with sufficient comments. Each function should be preceded by a header comment that describes what the function does. The code should be easy to read, properly indented, employ good naming standards, and structure, and correctly implement the design. Your code should match your design. CourseNana.COM

In case your code cannot be compiled or does not give the correct result, you may still get part of the implementation scores according to the quality and degree of correctness of the codes. CourseNana.COM

Evaluation (40 %) CourseNana.COM

The evaluation of your two programs will account for 40% of your project grade, with 20% for each Problem 1 and Problem 2. Your programs will be tested for correctness validation, ensuring that they work correctly. For each problem, the grading team will test your program based on both the test programs you have implemented and additional test cases specific to each problem. CourseNana.COM

CourseNana.COM

Submission CourseNana.COM

Please submit the following files:Source code files of basekernel together with your own implemented source code for both problems (including the modified Makefile).
Project report in PDF format based on report template for Project B. It should be named as CourseNana.COM

XX-report.pdf”, where XX represents your number. CourseNana.COM

Please organize and compress the above listed files in a zip format file (named as “XXproject.zip”): CourseNana.COM

/XX-project CourseNana.COM

 |── source code
 |── XX-report.pdf    <- The project report file.

Academic Honesty
All work must be developed by each independently. Please write your own code. All submitted source code will be scanned by anti-plagiarism software. We will both test your code and carefully check your source code. If your submitted code does not work, please indicate it in the report clearly.  CourseNana.COM

Get in Touch with Our Experts

WeChat WeChat
Whatsapp WhatsApp
HK CityU代写,CS3103代写,Operating Systems代写,Process Scheduler代写,Priority Scheduling Policy代写,QEMU代写,C代写,Named PIPE代写,HK CityU代编,CS3103代编,Operating Systems代编,Process Scheduler代编,Priority Scheduling Policy代编,QEMU代编,C代编,Named PIPE代编,HK CityU代考,CS3103代考,Operating Systems代考,Process Scheduler代考,Priority Scheduling Policy代考,QEMU代考,C代考,Named PIPE代考,HK CityUhelp,CS3103help,Operating Systemshelp,Process Schedulerhelp,Priority Scheduling Policyhelp,QEMUhelp,Chelp,Named PIPEhelp,HK CityU作业代写,CS3103作业代写,Operating Systems作业代写,Process Scheduler作业代写,Priority Scheduling Policy作业代写,QEMU作业代写,C作业代写,Named PIPE作业代写,HK CityU编程代写,CS3103编程代写,Operating Systems编程代写,Process Scheduler编程代写,Priority Scheduling Policy编程代写,QEMU编程代写,C编程代写,Named PIPE编程代写,HK CityUprogramming help,CS3103programming help,Operating Systemsprogramming help,Process Schedulerprogramming help,Priority Scheduling Policyprogramming help,QEMUprogramming help,Cprogramming help,Named PIPEprogramming help,HK CityUassignment help,CS3103assignment help,Operating Systemsassignment help,Process Schedulerassignment help,Priority Scheduling Policyassignment help,QEMUassignment help,Cassignment help,Named PIPEassignment help,HK CityUsolution,CS3103solution,Operating Systemssolution,Process Schedulersolution,Priority Scheduling Policysolution,QEMUsolution,Csolution,Named PIPEsolution,