Linux Process understanding and practice (1) Basic concepts and programming Overview (fork, vfork, cow)Process and program what is a program? A program is a set of commands to complete a specific task. What is a process? [1] from the user's perspective: A process is an execution process of a program [2] from the core of the operating system: A process is the basic unit of resources such as memory and CPU time slice allocated by the operating system. [
#include#include{ pid_tpid; pid=fork(); if(pid else printf("iamtheparentprocess,myprocessidis%d/n",getpid());}
The result is[Root @ localhost C] #./A. OutI am the child process, my process ID is 4286I am the parent process, my process ID is 4285
To understand the execution process of fork, we must first clarify the concept of "process" in the operating system. A process mainly contains three elements:
O.
The meaning of fork
The following figure is the storage space layout of the C program (typical)
1. An existing process can invoke the fork function to create a new process.The 2.fork function is called once, but returns two times, and the only difference that is returned two times is that the return value of the subprocess is 0, and the return value of the pa
Binary tree is a very common and useful data structure, which combines the advantages of an ordered array with a linked list. Finding data in a binary tree is as fast as finding data in an array, and adding and removing data in a binary tree is as efficient as it is in a linked list, so the relevant technology of binary tree has always been a must in the programmer's interview test.
Basic knowledge
Basic concepts
Properties
Examples of binary trees
When fork, source, and exec are used to run the script in fork mode, shell (parentprocess) generates a childprocess to execute the script. when childprocess ends, the difference between running scripts of parentpro fork, source and exec is returned.
When the fork method is used to run the script, the shell (parent proc
A simple guide to fork on Github and Git
In my experience, one of the most troublesome things I encountered when I first came into contact with Git and GitHub was to try to solve the following problem: What can I do on Git and GitHub?
Git tutorials often do not solve this problem, because they focus on teaching you Git commands and concepts, and do not think you will use GitHub. The GitHub help tutorials make up for this defect to some extent, but eac
level. The interrupted programs need to save the state of the interrupted time (that is, the three parts of the process must be recorded), so that the re-execution can completely recover to the past of the interrupted, if the interrupted time is short enough, it should give people a smooth feeling, that is why we can listen to music while reading this article. I guess that's why a program running in the memory is called a process.In this way, we can start to discuss the
deletion is not the same as the file system tree we simulated between us), and what we need to understand is why it can support binary lookups. As I said before, the reason why the list "does not support" binary lookup is that we have to "go through" the nodes in front (or behind) when we visit an intermediate node, so how does the two tree avoid this process? Very simple, let's take a step-by-step look.A little analysis of binary search, we are not difficult to find that the basic requirement
Introduction
"Less common in Java" This module has not been written for a long time, today write a Java fork/join distributed processing mode. Fork/join is introduced in JDK1.7, it can achieve simple map-reduce operation in some way. The author currently organized some blog for the interview are ultra-high frequency. You can click on the link: http://blog.csdn.net/u012403290. Technical Points
1, Map-reduce
Three different methods (fork, exec, source) fork (/directory/script. sh) fork is the most common, that is, directly using/directory/script in the script. sh to call the script. sh script. run a sub-shell script to execute the call. When sub-shell is executed, parent-shell is still running. After sub-shell is executed, return parent-shell. sub-shell inherits envi
This article is for [Data Structure Basic series (6): Tree and two fork tree] 第1-10 hours1 tree structure guided studies2 Basic concepts of trees3 basic terms of the tree4 Nature of the tree5 storage structure of the tree62 Fork Tree Concept and properties72 cross-tree and tree, forest conversion82 the storage structure of the fork treeBasic operation and impleme
//define data typestypedef enum{link, Thread} pointertag; //link = 0 means pointing to the left and right child pointer, thread = 1 indicates a precursor or successor to the typedef struct bitnode{ char data; //node Data struct BitNode * Lchild; //Kids hands struct Bitnode *rchild;pointertag Ltag; //flag pointertag Rtag;} Bitnode, *bitree;bitree Pre; //global variable, always points to the node you just visited //Pre-order Create two-fork treevoi
Stumbled, Unix also saw the process management, suddenly feel tall on the. However, in the face of the first system call fork, this English pronunciation is really lame, almost enrolled into ~ ~.In Unix, there is a unique process ID (PID) for any process, but there are many other properties besides the process ID: Parent process ID (ppid), process actual user ID, process valid user ID, process actual user group ID, process valid user group ID. For the
IBM developer articles are good, there is no saying that the use of GDB multi-process debugging Tian Qiang (tianq@cn.ibm.com ),Software Engineer, IBM China Software Development CenterIntroduction:GDB is a common debugging tool in Linux. This article describes several methods for debugging multi-process programs using GDB and compares various methods.Mark this article!Release date:July 30, 2007Level:IntermediateAccess:10160 viewsComment:0 (View | Add comment-Log On)Average score (7 scores)Score f
One, the process replicates (or produces)The child processes obtained by using the fork function inherit the entire process's address space from the parent process, including: process context, process stack, memory information, open file descriptor, signal control settings, process priority, process group number, current working directory, root directory, resource limit, control terminal, and so on.The difference between a child process and a parent p
resource management, and the thread is the smallest unit of program execution.In a Linux system, POSIX threads can "be considered" as a lightweight process, pthread_create create threads and fork creation processes are created by invoking the __clone function in the kernel, except when the option to create a thread or process is different. For example, whether to share virtual address space, file descriptors, and so on.Fork and multithreadingWe know
Oberbaun describes the linear structure of the data structure, we introduce the nonlinear structure of this blog-tree and two-fork tree. I would like to introduce some basic concept tree, tree traversal, and then introduce the concept and characteristics of the two-fork tree. And a two-fork tree traversal. Cross-tree control, summary.Tree in order to describe the
Binary tree definition: The two fork tree is a set of N (n>0) finite nodes. N=0 tree becomes i empty binary tree; The tree of n>0 has a root node and two sub-binary trees, called Saozi right subtree, respectively, which means that each node is either a left or right tree or a left tree, or a subtree.A binary tree is an ordered tree, and a binary tree is a Zuozi or a right subtree even when there is only one subtree.Full two
Data structure of the Clue two fork treeenum PointerTag//枚举{ Link,Thread//Link(0):指针;thread(1):线索};struct BiThrNode{ TElemType data;//结点的值 BiThrNode * lchild, *rchild;//左右孩子结点 2;//左标志,占2bit 2;//右标志,占2bit};typedef BiThrNode *BiThrTree;Basic operation of the Clue two fork treevoidCreatebithrtree (BithrtreeT) {//Enter the value of the node in the first order input thread two
(1) Definition of fork ()The fork () function is the only way to derive a new process from UNIX, declared as follows:[CPP]View Plaincopy
#include
pid_t fork (void);
What we need to understand is that by invoking the fork () method, the method returns two times. Once is returned once in the call
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.