


Table of Contents
1. Design purpose and requirements
2. Design content
3. Equipment and environment
4. Design thinking
5. Main data structures and processes
6. Experimental test results and result analysis
7. Summary of course design
Attachment 1 Course Design Defense Record
Attachment 2 source program list
1. Design purpose and requirements
This course is designed to enable middle school students to understand the implementation principles of Linux system calls, master how to change the Linux kernel source code, and how to compile calling programs to call new system calls. Middle school students are required to complete this course independently and understand the concept and implementation of system calls.
2. Design content
Using the compiled kernel methodoperating system principles and Linux system experiments, recompile the Linux kernel and reduce a system call in Linux.
Requirements: (1) Function implemented by system call: estimate the cube of a number and copy it. (2) Write another program to call.
3. Equipment and environment
Device: VMware Workstation Pro
Environment: Ubantu15.0.2
Image: ubuntu-16.04-desktop-amd64.iso
4. Design Thought 4.1 Design Idea
Change the Linux kernel and lower a new system call to implement the function of estimating the cube of a number and copying it, including downloading the Linux kernel source code, making changes, compiling the changed Linux kernel, and installing it into the system, Write a program that calls this new system call.
4.2 Main steps
(1) View the original kernel:
(2)Download the new kernel:
wgetOperating system principles and Linux system experimentLinux transplantation, then press Enter. The result is as shown
(3)將下載好的安裝包聯通到/usr/src目錄下,之後解壓縮.,終端機輸入如下指令,結果如圖
mvlinux-5.6.15.tar.gz/usr/src
cd/usr/src
tar-xvflinux-5.6.15.tar.gz
(4)下載超級編輯器vim(先前已下載好),我這兒早已下載好,若沒下,可以使用sudoapt-get-yinstallvim進行下載
(5)新增系統呼叫:
新增呼叫函數申明:viminclude/linux/syscalls.h
在#ifndef前面加asmlinkagelongsys_cube(intnum);
註:i步入編輯模式,加入後Esc返回linux移植,最後shiift+:敲wq儲存退出。
(6)加入呼叫函數定義,輸入vimkernel/sys.c,在文末加入函數
SYSCALL_DEFINE1(cube,int,num){
intresult=numnumnum;
printk(“Theresultis%d.n”,result);
returnresult;
(7)新增系統呼叫號碼
輸入vimarch/x86/entry/syscalls/syscall_64.tbl,在syscall_64.tbl檔案中加入439項內容
(8)安裝編譯核心所需的依賴套件:
apt-get -y install make apt-get -y install libncurses5-dev apt-get -y install flex apt-get -y install bison apt-get -y install libssl-dev apt-get -y install libelf-dev
(9)配置內核
輸入makemenuconfig,在跳出的介面中依序執行【Save】—>【Ok】—>【Exit】—>【Exit】
(10)編譯
在【終端】中鍵入make-j8(8個執行緒開始編譯),大約一個小時左右,如圖所示編譯完成
鍵入makemodules、makemodules_install指令,分別完成模組的編譯和安裝作業。
(11)安裝內核
【終端】輸入makeinstall
(12)重啟系統
【終端】輸入uname-r,查看核心版本,如圖所示已對核心重新編譯
編撰呼叫程式:
保存後退出,在【終端】中依序執行gcctest.c-otest.out、./test.out即可得到測試結果
五、主要資料結構與流程
The above is the detailed content of A Deep Dive into Linux System Calls: New System Call to Cube a Number and Print It. For more information, please follow other related articles on the PHP Chinese website!

The Linux command line interface provides a wealth of text processing tools, one of the most powerful tools is the sed command. sed is the abbreviation of Stream EDitor, a multi-functional tool that allows complex processing of text files and streams. What is Sed? sed is a non-interactive text editor that operates on pipeline inputs or text files. By providing directives, you can let it modify and process text in a file or stream. The most common use cases of sed include selecting text, replacing text, modifying original files, adding lines to text, or removing lines from text. It can be used from the command line in Bash and other command line shells. Sed command syntax sed

Efficiently Counting Files and Folders in Linux: A Comprehensive Guide Knowing how to quickly count files and directories in Linux is crucial for system administrators and anyone managing large datasets. This guide demonstrates using simple command-l

Efficiently managing user accounts and group memberships is crucial for Linux/Unix system administration. This ensures proper resource and data access control. This tutorial details how to add a user to multiple groups in Linux and Unix systems. We

Linux Kernel is the core component of a GNU/Linux operating system. Developed by Linus Torvalds in 1991, it is a free, open-source, monolithic, modular, and multitasking Unix-like kernel. In Linux, it is possible to install multiple kernels on a sing

This brief guide explains how to type Indian Rupee symbol in Linux operating systems. The other day, I wanted to type "Indian Rupee Symbol (₹)" in a word document. My keyboard has a rupee symbol on it, but I don't know how to type it. After

Introduction In the realm of Linux, where the command line is often the compass by which we navigate, the efficient management of disk space is crucial. Whether you’re sailing through personal projects or steering the ship o
![Install Fedora Linux 41 Workstation [Step-by-Step Guide]](https://img.php.cn/upload/article/001/242/473/174149047084567.png?x-oss-process=image/resize,p_40)
This guide provides a comprehensive walkthrough for installing Fedora Linux 41 Workstation Edition. Let's get started! Table of Contents - Step 1: Prepare Your Fedora 41 Installation Media Step 2: Boot from the Fedora 41 Installation Media Step 3:

Linus Torvalds has released Linux Kernel 6.14 Release Candidate 6 (RC6), reporting no significant issues and keeping the release on track. The most notable change in this update addresses an AMD microcode signing issue, while the rest of the updates


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

SublimeText3 Mac version
God-level code editing software (SublimeText3)

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),