Unix编程基础(1)--系统概述

Unix系统概述

UNIX的系统架构

一个比较直观的认识是,操作系统
unix系统架构

kernel:运行于硬件之上
系统调用(system call): 内核的接口

登录

登录名
shell

文件和目录

文件系统
文件名
路径名

输入和输出

文件描述符
标准输入,标准输出和标准错误
不带缓冲的IO

程序和进程

程序
进程和进程ID

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
int main() {
printf("this pid is %ld\n", (long)getpid());
printf("this ppid is %ld\n", (long)getppid());
for(;;) {
}
return 0;
}
/***
pstree
─gnome-terminal─┬─gnome-pty-helpe
│ │ │ │ ├─zsh───sh───node───8*[{node}]
│ │ │ │ ├─5*[zsh───ssh]
│ │ │ │ ├─5*[zsh]
│ │ │ │ ├─zsh───mongo───2*[{mongo}]
│ │ │ │ ├─zsh───python─┬─python───5*[{+
│ │ │ │ │ └─4*[{python}]
│ │ │ │ ├─2*[zsh───python]
│ │ │ │ ├─zsh───a.out
**/

进程控制
线程和线程ID

1
2
3
4
5
6
SYNOPSIS
#include <sys/types.h>
#include <unistd.h>
pid_t getpid(void);
pid_t getppid(void);

错误处理

用户标识(User-id)

信号(Signals)

时间(Time Value)

系统调用和库函数

坚持技术分享,您的支持将鼓励我继续创作!