首页 | 资讯动态 | linux基础 | 系统管理 | 网络管理 | 编程开发 | linux数据库 | linux相关 | linux认证 | 下载中心 | 专题
oklinux
 系统管理:中文环境 系统管理 桌面应用 内核技术 Linux基础:安装配置 常用命令 经验技巧 软件应用 Linux数据库:Mysql POSTGRE
 网络管理:网络安全 网络应用 Linux服务器 编程开发:PHP CC++ Python Perl SHELL 嵌入式开发 | PHP基础 PHP技巧 PHP应用 PHP文摘
 首页 linux资讯动态 Linux专题 | 其他Unix Linux解决方案 硬件相关 Linux认证 企业应用 Apache | 相关下载:资料 参考手册 开发工具
 → 当前位置:首页>系统管理>内核技术>正文

Kernel command using Linux system calls

OKLinux www.oklinux.cn 2007-03-28 来源:IBM developerWorks Worldwide 会员收藏 游客收藏

Level: Intermediate

M. Tim Jones ([email protected]), Consultant Engineer, Emulex

21 Mar 2007

Linux® system calls -- we use them every day. But do you know how a system call is performed from user-space to the kernel? Explore the Linux system call interface (SCI), learn how to add new system calls (and alternatives for doing so), and discover utilities related to the SCI.

A system call is an interface between a user-space application and a service that the kernel provides. Because the service is provided in the kernel, a direct call cannot be performed; instead, you must use a process of crossing the user-space/kernel boundary. The way you do this differs based on the particular architecture. For this reason, I'll stick to the most common architecture, i386.

In this article, I explore the Linux SCI, demonstrate adding a system call to the 2.6.20 kernel, and then use this function from user-space. I also investigate some of the functions that you'll find useful for system call development and alternatives to system calls. Finally, I look at some of the ancillary mechanisms related to system calls, such as tracing their usage from a given process.

The SCI

The implementation of system calls in Linux is varied based on the architecture, but it can also differ within a given architecture. For example, older x86 processors used an interrupt mechanism to migrate from user-space to kernel-space, but new IA-32 processors provide instructions that optimize this transition (using sysenter and sysexit instructions). Because so many options exist and the end-result is so complicated, I'll stick to a surface-level discussion of the interface details. See the Resources at the end of this article for the gory details.

You needn't fully understand the internals of the SCI to amend it, so I explore a simple version of the system call process (see Figure 1). Each system call is multiplexed into the kernel through a single entry point. The eax register is used to identify the particular system call that should be invoked, which is specified in the C library (per the call from the user-space application). When the C library has loaded the system call index and any arguments, a software interrupt is invoked (interrupt 0x80), which results in execution (through the interrupt handler) of the system_call function. This function handles all system calls, as identified by the contents of eax. After a few simple tests, the actual system call is invoked using the system_call_table and index contained in eax. Upon return from the system call, syscall_exit is eventually reached, and a call to resume_userspace transitions back to user-space. Execution resumes in the C library, which then returns to the user application.


Figure 1. The simplified flow of a system call using the interrupt method
Simplified flow of a system           call

At the core of the SCI is the system call demultiplexing table. This table, shown in Figure 2, uses the index provided in eax to identify which system call to invoke from the table (sys_call_table). A sample of the contents of this table and the locations of these entities is also shown. (For more about demultiplexing, see the sidebar, "System call demultiplexing.")


Figure 2. The system call table and various linkages
共8页: 上一页 1 [2] [3] [4] [5] [6] [7] [8] 下一页
上一篇:Novell称微软专利许可观点“强奸民意”   下一篇:Linux and symmetric multiprocessing

收藏于收藏夹】 【评论】 【推荐】 【投稿】 【打印】 【关闭

相关文章
·Linux and symmetric multiprocessing
·通过Linux内核观察/proc/pid/statm
·Linux内核源代码的目录结构简单介绍
·按需对Linux系统内核进行定制和修改
·将驱动及应用软件移植到Linux2.6内核
·全面了解Linux操作系统核心配置文件
·三分钟编译支持NTFS的Linux系统模块
·linux内核启动地址的确定
·ubuntu 6.10 下编译2.6.19内核并安装NVIDIA
·教菜鸟编译自己的内核2.6.19
发表评论
密码: 匿名评论
评论内容:(不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。)
站内搜索
阅读排行榜
·基于S3C44B0微处理器的uCl
· 深入理解LINUX内核中文版
·Linux操作系统的内核编译
·Process priority and con
·Linux 2.6内核如何武装Fed
·通过振动向Linux ThinkPad
·主流嵌入式Linux系统下GUI
·推荐:Linux用户态与内核
·用命令行加挂Linux的文件
·Linux系统内核接收以太帧
最新文章
·用Tftp向目标板烧写Linux
·交叉编译Linux内核(2.6.22
·UNIX操作系统的加锁解锁:
·基于2.6.9内核小型Linux系
·Linux系统中使用GCC CPU参
·Linux系统的引导过程详细
·Linux系统的内核初始化过
·Linux系统高手之路 内核编
·Linux高手之内核编译过程
·Linux系统内核模块和驱动
·Linux系统下编译支持NTFS
·Linux系统中用内核KHTTPD
·Linux系统内核分析 使用GD
·Linux操作系统的内核解读
·通过Linux系统的内核观察/

设为首页 - 加入收藏 - 版权声明 - 广告服务 - 关于我们 - 联系我们 - 友情连接
Copyright © 2007 All rights reserved OKLinux.Cn 版权所有
合作联系 QQ:18743986 Email:arlan8005#163.com