代写范文

留学资讯

写作技巧

论文代写专题

服务承诺

资金托管
原创保证
实力保障
24小时客服
使命必达

51Due提供Essay,Paper,Report,Assignment等学科作业的代写与辅导,同时涵盖Personal Statement,转学申请等留学文书代写。

51Due将让你达成学业目标
51Due将让你达成学业目标
51Due将让你达成学业目标
51Due将让你达成学业目标

私人订制你的未来职场 世界名企,高端行业岗位等 在新的起点上实现更高水平的发展

积累工作经验
多元化文化交流
专业实操技能
建立人际资源圈

System_Call

2013-11-13 来源: 类别: 更多范文

Operating Systems Tutor: Colm Donohoe 12/6/2010 Author: Domas Zelionis Table of Contents Introduction 2 System Call Research 3 System Call Definition 3 The Environment 6 Implementing System Call 7 The Program 7 Program ‘newprocess’ Explained 8 Program ‘killer’ Explained 9 Compiling 10 Testing 11 Summary 12 References 12 Bibliography 12 Introduction Before anyone can write software for a particular operating system, they must first understand the programming interfaces the system provides. So, in this project we will explain and implement system call in Linux. System Call Research In any modern operating system, virtual memory is divided into two spaces. One is used to run code in privileged mode, known as kernel space and another for executing user applications. Kernel code has complete control over the machine; it can access any of the machine’s resources, such as memory, network adapters, and disk drives. User space code has limited access to system resources. In order to read from a disk drive or write to the network, for example, user code has to ask the kernel to perform the operation. So, in this stage system call is involved, it allows user space programs to request services from the kernel. System Call Definition | A system call, sometimes referred to as a kernel call, is a request in a Unix-like operating system made via a software interrupt by an active process for a service performed by the kernel. A process (also frequently referred to as a task) is an executing (i.e., running) instance of a program. An active process is a process that is currently progressing in the CPU (central processing unit), as contrasted with processes that are waiting for their next turns in the CPU. An interrupt is a signal to the kernel that an event has occurred, and this results in changes in the sequence of instructions that is executed by the CPU. A software interrupt, also referred to as an exception, is an interrupt that originates in software, usually by a program in user mode. User mode is one of two distinct execution modes of operation for the CPU in Linux. It is a non-privileged mode in which each process starts out. It is non-privileged in that processes in this mode are not allowed to access those portions of memory that have been allocated to the kernel or to other programs. The kernel is a program that constitutes the core of an operating system, and it has complete control over all resources on the system and everything that occurs on it. When a user mode process (i.e., a process currently in user mode) wants to utilize a service provided by the kernel (i.e., access system resources other than the limited memory space that is allocated to the user program), it must switch temporarily into kernel mode, also called system mode, by means of a system call. Kernel mode has root (i.e., administrative) privileges, including root access permissions (i.e., permission to access any memory space or other resources on the system). This allows the operating system to perform restricted actions such as accessing hardware devices or the memory management unit (MMU). When the kernel has satisfied the request made by a process, it restores that process to user mode. The MMU is a type of circuitry that is responsible for handling memory access requested by the CPU. System calls can also be viewed as clearly-defined, direct entry points into the kernel through which programs request services from the kernel. They allow programs to perform tasks that would not normally be permitted. Examples of the services performed by the kernel include as input/output (I/O) and process creation. The former can be defined as any movement of data to or from the combination of the CPU and main memory (i.e. RAM), that is, communication between this combination and the computer's users (e.g., via the keyboard or mouse), its storage devices (e.g., disk or tape drives) or other computers. Process creation is the creation of a new process. A system call is accomplished in Linux on x86 (i.e., Intel-compatible) processors by calling the interrupt 0x80 (i.e., int 0x80) together with the register values. A register is a very small amount of high speed memory inside of the CPU. int 0x80 is the assembly language instruction that is used to invoke system calls in Linux on x86 processors. The calling of this instruction is preceded by the storing in the process register of the system call number (i.e., the integer assigned to each system call) for that system call and any arguments (i.e., input data) for it. System calls can be classified into six groups: process management, interprocess communication, memory management, file system, initialization and other. The kernel maintains a list of all registered system calls in the system call table. This table assigns each valid system call a unique system call number which cannot be changed or recycled. Processes do not refer to system calls by name, but rather by their system call number. [ (Bellevue Linux Users Group, 2006) ] | | The Environment To implement system call , environment I used: * Ubuntu 10.04.1 operating system (version of Linux) * Kernel , version 2.6.32-26-grneric. * Bash shell – command-line interpreter (figure on this page). * C /C++ programming language. * vim – command-line text editor (figure on next page). * gcc – GNU project C/C++ compiler. * make – GNU make utility to maintain groups of programs. * ps – reports a snapshot of the current processes. * grep – prints lines matching a pattern. Implementing System Call There are more than thousand system calls available in Linux operating system. However, I will demonstrate few of them: * fork() - creates a child process that differs from the parent process only in its PID (process identifier) * getpid() – get the process ID of the current process. * kill() - send signal to a process. The Program My program, actually, is made of two programs, which I called ‘newprocess’ and ‘killer’. First one is like a background process without user intervention. On run it creates a child process, which outputs child pid on a screen and goes in to infinite loop. Basically, that means that to stop it, you can only kill it. To kill it – is my second program task. It inputs pid as command line argument and sends quit signal to given process. Program ‘newprocess’ Explained Program ‘killer’ Explained Compiling To compile program, I used GNU make utility, which requires configuration file called ‘Makefile’. So, in figure below I show contents of my Makefile, and how simple is compile or recompile program just running ‘make’ utility. Testing Figure below demonstrates how testing was done. * I ran ‘newprocess’ program two times and I get to separate background processes. * I matched programs output pid with ‘ps’ utility * I ran ‘killer’ with no command line arguments and it printed help. * I killed background processes, using ‘killer’. Also I tried to kill invalid pid. Summary System calls are the main interface between processes and the OS * System calls are like an extended “instruction set” for user programs that hide many details. * First Unix system had a couple dozen system calls. * current systems have a couple hundred. Understanding the system call interface of a given OS lets you write useful programs under it. References Bellevue Linux Users Group. (2006, April 27). System Call Definition. Retrieved 11 20, 2010, from The Linux Information Project (LINFO): http://www.linfo.org/system_call.html Troan, E. (1999, 05 15). Introduction to System Calls. Retrieved 11 20, 2010, from linux-mag: http://www.linux-mag.com/id/217 Bibliography http://en.wikipedia.org/wiki/System_call http://tldp.org/HOWTO/html_single/Implement-Sys-Call-Linux-2.6-i386/ http://khup.com/download/7_keyword-unix-system-calls/operating-systems-and-unix.pdf http://khup.com/download/18_keyword-linux-system-calls/cs-153-lab1.pdf http://linux.die.net/man/2/syscalls http://linux.die.net/man/2/fork http://linux.die.net/man/2/getpid http://linux.die.net/man/2/kill http://linux.die.net/man/7/signal Linux online reference manuals
上一篇:Teaching_Assistants_Role 下一篇:Strategic_Management