BEST代写-线上编程学术专家

Best代写-最专业靠谱代写IT | CS | 留学生作业 | 编程代写Java | Python |C/C++ | PHP | Matlab | Assignment Project Homework代写

C语言代写 | CMPT 300 Assignment 4: System Calls

C语言代写 | CMPT 300 Assignment 4: System Calls

本次加拿大CS代写主要是使用C语言实现操作系统OS的进程处理

CMPT 300 Assignment 4: System Calls

Total marks: 100
Overall percentage: 13% Due: Apr 19 (10am Pacic)

This assignment may be completed idividually or in a group (up to three people).

Note: As usual, all code must be written in C and run on a Linux machine. We will grade your code on a Linux machine. You should create a directory for this assignment, such as ~/cmpt300/a4/ and put all les related to this assignment in it.

Please follow the text below to understand the context, and attempt to nish the problems described.

1. Preparation

To complete this assignment, it is vital that you have carefully completed and understood the content in the following guides:

Custom Kernel Guide: how to download, build, and run a custom Linux kernel.
Guide to Linux System Calls: how to create and test a simple Linux system call (syscall). Guide to Generating Kernel Patches: how to generate patches for the Linux kernel.

You may also consult the ocial The Linux kernel documentation for reference: Unreliable Guide To Hacking The Linux Kernel

Adding a New System Call

In this assignment, you will be coding in both user space and kernel space. Since it could take a couple of minutes to recompile and re-run a new kernel, you should code carefully!

2. The Array Statistics Syscall

First, add a new system call that computes some basic statistics (max, min, sum) on an array of data. In practice, it makes little sense to have this as a syscall; but it allows you to become familiar with accessing memory between user and kernel space before solving more complex and real problems that involve the interaction between kernel and user space.

2.1 Specications
In the kernel’s cmpt300 directory, create a le named array_stats.h with the following contents:

Then create a new syscall named array_stats (function sys_array_stats()):

Implement it in your kernel’s cmpt300 directory in a le named array_stats.c, using your previously dened array_stats.h header le: #include “array_stats.h”.
Assign syscall number 437 to the new syscall (in syscall_64.tbl).
The syscall’s signature should be:

stats: A pointer to one array_stats structure allocated by the user-space application. Structure will be written to by the sys-call to store the minimum, maximum, and sum of all values in the array pointed to by data.
data: An array of long int values passed in by the user-space application.

size: The number of elements in data. Must be greater than 0. The array_stats syscall must:

Set the three elds of the stats structure based on the data array. The values in data are signed (positive or negative). Nothing special need be done if the sum of all the data overows/underows a long.
Return 0 when successful.
Return -EINVAL if size <= 0.
Return -EFAULT if there is any error accessing stats or data.
Not allocate or use a large amount of kernel memory to copy the entire input data array from user space.

bestdaixie

评论已关闭。