Unix Processes(1)
来源:互联网 发布:win10无法连接windows 编辑:程序博客网 时间:2024/05/22 04:38
1.All processes are provided with a set of memoru addresses, called a virtual address space;
2.A process's prcess control block(PCB) is maintained by the kernel in a protected region of memory taht user processes cannot access
3.A Unix PCB stores: the contents of the processeor registers, Process ID(pid), the program counter and the system stack,all processes are listed in the process table.
4.All processes interact woth OS via system calls. To spawn a child process ,using the <a>fork</a> system, which creates a copy of the parent process (child receives a copy of the parent's resources as well)
5.Process priorities are integers b/t -20 and 19(inclusive), a lower numerical priority value indicates a higher scheduling priority
6.Unix provides inter-process communication(IPC) mechanisms ,such as pipes ,to allow unrelated process transger data
System calls
7. All processes run in separate address spaces;e.g. process A and B has same address 520,when B rites to address 520, the
contents of 520 for A is not changed.
e.g.--create two child processes
/* This program creates two new children processes. */#include <sys/types.h> /* file of data types needed for many compilers */#include <unistd.h> /* needed for fork, getpid procedures */#include <stdio.h>#include <signal.h>void procont(){ printf("Process 1 paused. It will resume soon.\n"); }int main (void){ pid_t pid1; /* variable to record process id of child 1 */ pid_t pid2; /* variable to record process id of child 2 */ pid_t pid; /* fork system call creates a new process by duplicating the parent process's address space stack and open file descriptors */ pid1 = fork(); if (pid1 == -1) /* check for error in spawning child process */ { perror ("error in fork"); exit (1); } if (pid1 == 0) /* check if this is the new child process */ { /* processing for child 1 */ signal(SIGUSR1,procont); pause(); sleep(2);printf ("This output comes from the 1st child process\n"); } else { pid2 = fork(); /* create child 2 */if (pid2 == -1) /* check for error in spawning child process */{ perror ("error in fork"); exit (1);}if (pid2 == 0) { /* check if this is the new child process */ sleep(2); printf ("This output comes from the 2nd child process\n"); kill(pid1,SIGUSR1);}else { /* processing for parent */ int s; pid = wait(&s); pid = wait(&s); printf ("This output comes from the parent process.\n"); printf ("Parent report: my pid = %d child1's pid = %d, child2's pid = %d\n", getpid(), pid1, pid2); } } exit (0); /* quit by reporting no error */}
wait(stat_loc) : allows the parent process to ait for its children to terminate;returns the pid of the child rpocess that is being traced; stores status info. about the child at the location pointed to by the stat_loc param.
- Unix Processes(1)
- 《Working with Unix Processes》-理解Unix进程笔记
- processes 1 启动进程
- Processes
- Processes
- Scheduling R scripts and processes on Windows and Unix/Linux
- The lists of TASK_RUNNING processes 1
- Understanding HDFS Recovery Processes (Part 1)
- Understanding HDFS Recovery Processes (Part 1)
- [RL] 3 Finite Markov Decision Processes (1)
- Yandex Big Data Essentials Week1 Unix Command Line Interface Processes managing
- system函数错误返回-1 错误原因NO child processes
- Unkillable Processes
- Software Processes
- Multiple Processes
- processes参数设置
- lightoj1301Monitoring Processes
- Spawning Processes
- 如何在ns2中实现一个简单的网络协议
- Server side evaluation of Gridview Data
- Java 虚拟机体系结构
- 一些基本算法(全文转载)
- asterisk chan_ss7 双链路
- Unix Processes(1)
- python操作mysql
- Web应用中防止用户重复登录的简单实现方法
- command line warning #10006: ignoring unknown option '/NODEFAULTLIB'错误解决(XPDF编译时出现的问题)
- sql用法
- UPDATE语句中的WHERE条件
- asterisk chan_ss7 单链路
- PPTP CLIENT
- java反射机制简介