6.1, the overall idea of the Linux program
The init process is the first process initiated by the Linux kernel, it is the initiator of all subsequent processes. The init process of this system is a link to the rc process, so the rc process is the main process, which is the program that runs into the kernel first. Initially, other child processes are started in the main process program. Suspend the wait process signal.
The child process does something to process or start or shut down other child processes by signaling the main process, the main process receives the signal. In addition, some processes communicate through socket sockets.
For some processes, the program runs once and exits. Some processes are programs that run continuously.
6.1, rc program
The main sequence is named rc, init, ip-up, ip-down, dtu-dns, start_watchdog, start-lan, stop-lan, start_timer, etc. Processes are connections to rc. When running these processes, the rc process determines which handlers to execute based on the process parameters.
If you run the init indicator, you will enter the RC main loop.
6.3, initialization runtime environment
The main loop includes the following parts of the initialization:
1, system initialization
mount system related directory
Generation of all device nodes
Mounting flash partition related directories
Creating links to parameter files
Creating related directories
Device parameter initialization
Console Initialization
Kernel Module Load
Time Zone Settings, System Time and Hardware Synchronization
Built-in Hardware Watchdog Startup
External hardware watchdog startup
2, GPIO initialization
Turn off the relevant indicator, turn on the module power, turn off the power of the sub-board
Turn off the unused GPIO
Turning on the power of the daughter board
Initializing each module
3. Turning on the LAN
4. Initializing the signal
Initializing the signal
Registration Signal
5, Configuration File Initialization
PPP Dialing Related Configuration File
DTU Parameters Configuration File
Network Controller Parameter Configuration File
Phone or SMS Trigger Configuration File
ICMP Detection Configuration File
DNS Detection Configuration File
DDNS parameter configuration file
Maintenance channel parameter configuration file
6.4, running various processes
1. Open TCP local server
Figure:
Figure 6.2 Local server process flow chart
2, open various services
Httpd server open
DTU client connection open < Br>
Dhcpd service is turned on
Telnet service is turned on
Monitoring the number of duplicate processes is turned on
Traffic statistics are turned on
6.5, ensuring that the PPPD process is correct Run
1. Before running pppd, first determine whether the module interface can be opened normally. If the exception is turned on, restart the system.
2. After running pppd, judge whether to generate /tmp/ppp/link. file every 1 second, and re-dial if it is not generated within the timeout period.
3, before re-run pppd to reset the module, disconnect the pppd connection to avoid the last run pppd did not exit.
4, pppd dial-up successfully open the network test function, to avoid pppd itself can not detect the drop.
6.6, run to loop processing
After the main program is initialized, the related service starts to enter the main loop processing, the main loop starts to dial the line and after the online processing, and finally idle Wait for an event signal. The main loop mainly monitors whether there is an abnormality in the PPPD and the WAN. If an abnormality is found, the corresponding processing is performed. The processing flow is as shown in the following figure:
Figure 6.3 Main Process Main Loop Flowchart
As above As you can see from the flowchart, the main loop is a state machine. When a process sends a signal, the signal processing function changes the state value, the main loop jumps out of the IDLE state, to the RESTART, or STOP state, loops again, and finally stabilizes to the idle state. It is common to run the ip-down process when the PPPD goes offline. The process sends a signal to the main process, and the main process goes to the RESTART state. The main program re-runs the dialing process.
6.7. Use of Signals
Signals are events that are generated by UNIX and Linux systems in response to certain conditions. The process that receives the signal takes some action accordingly. Usually the signal is generated by an error. But they can also be explicitly sent from one process to another as a way to communicate or modify behavior between processes. The generation of a signal is called generation, and a signal is received called capture.
Need to include the header file: #include <signal.h>
The use of the signal includes the following steps:
1. Register a signal.
For example: signal(SIGHUP, rc_signal);
2. Signal processing function.
static void rc_signal(int sig)
{
……
if (sig == SIGHUP) {
Syslog(6,"signalling RESTART\ ");
signalled = RESTART;
}
……
}
3. Send signal
Signal the main process: kill(1, SIGHUP);
Today, I will share 11 cool Linux terminal commands compiled by Linux for ten years. Through
The Windows 7 and Ubantu dual system are installed on the computer. Since the Linux system
Today, Xiaobian is a beginner Linux developer to explain how to install Linux. Here Xiaobian
Some users of Linux systems often encounter, showing that the disk space is full, you have to delete
Detailed use of rz and sz commands in Linux
View cpu physics number, core number, logical cpu number under linux
Kali linux 2.0 installation under virtual machine
Linux service configuration network monitoring
How to create and unzip zip, tar, tar.gz and tar.bz2 files under Linux
Command Description for Suspending (Standby) in Linux
Linux system transfer files between
How does Win10 set the timer to wake up?
How to solve the problem of Win10 Xiaona slow response
How to add IIS function to Win7 system
Promotional price of 40 US dollars, Win8 RP version can be upgraded to Win8 official version
Win7 system boot does not start NVIDIA settings, how to do
Win10 prompts printer service when using printer. How to turn on printer service
Add file selection checkbox for Win7 Explorer (1)
A little bit better to improve BT download speed
How can I handle the Win10 system KBKB3124200? What should I do if the bug fixes?