当前系统调用都采用的是POSIX标准,POSIX标准以其简洁易用在类Unix操作系统中流行,以至于Linux从一开始就遵从POSIX标准。
本节介绍应用程序和操作系统之间的接口系统调用。采用的是 POSIX ,这个接口被 MINIX3, UNIX, Linux 等许多现代操作系统所遵循。系统调用以 C 语言的形式出现。
系统调用和普通过程调用的区别:系统调用时在内核状态执行, CPU 存在一个切换。普通过程调用不存在切换。
以读文件操作为例: count = read(fd, buffer, nbytes);
MINIX 系统主要的系统调用列表:
进程管理:
pid = fork();
pid = waitpid(pid, &statloc, opts);
s = wait(&status);
s = execve(name, argv, envp);
exit(status);
size = brk(addr);
pid = getpid();
pid = getpgrp();
pid = setsid();
信号 (singnals)
l = ptrace(req, pid, addr, data);
s = sigaction(sig, &act, &oldact);
s = sigreturn(&context);
s = sigprocmask(how, &set, &old);
s = sigpending(set);
s = sigsuspend(sigmask);
s = kill(pid, sig);
residual = alarm(seconds);
s = pause();
文件管理:
fd = create(name, mode)
fd = mknod(name, mode, addr)
fd = open(file, how, ...)
s = close(fd);
n = read(fd, buffer, nbytes)
n = write(fd, buffer,nbytes)
pos = lseek(fd, offset, whence)
s = stat(name, &buf)
s = fstat(fd, &buf)
fd = dup(fd)
s = pipe(&fd[0])
s = ioctl(fd, request, argp)
s = access(name, amode)
s = rename(old, new)
s = fcntl(fd, cmd, ...)
目录和文件系统管理
s = mkdir(name, mode)
s = rmdir(name)
s = link(name1, name2)
s = unlink(name)
s = mount(special, name, flag)
s = umount(special)
s = sync()
s = chdir(dirname)
s = chroot(dirname)
保护权限相关
s = chmod(name, mode)
uid = getuid()
gid = getgid()
s = setuid(uid)
s = setgid(gid)
s = chown(name, owner, group)
oldmask = umask(complmode)
时间管理
seconds = time(&seconds)
s = stime(tp)
s = utime(file, timep)
s = times(buffer)
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/hb_zxl/archive/2009/06/01/4234018.aspx