Android Training Course (14)

Source: Internet
Author: User

#200

#201 (;;){

#202 int nr, I, timeout =-1;

This Code enters the endless loop processing, so that the init process becomes a service.

 

#203

#204 for (I = 0; I <fd_count; I ++)

#205 ufds [I]. revents = 0;

This code clears the event count of each socket.

 

#206

#207 drain_action_queue ();

This code is the command in the execution queue.

 

#208 restart_processes ();

This code is used to determine which services need to be restarted.

 

#209

#210 if (process_needs_restart ){

#211 timeout = (process_needs_restart-gettime () * 1000;

#212 if (timeout <0)

#213 timeout = 0;

#214}

This code is used to determine the process startup timeout.

 

 

#215

#216 # if BOOTCHART

#217 if (bootchart_count> 0 ){

#218 if (timeout <0 | timeout> BOOTCHART_POLLING_MS)

#219 timeout = BOOTCHART_POLLING_MS;

#220 if (bootchart_step () <0 | -- bootchart_count = 0 ){

#221 bootchart_finish ();

#222 bootchart_count = 0;

#223}

#224}

#225 # endif

This code is used to calculate the running performance.

 

#226 nr = poll (ufds, fd_count, timeout );

#227 if (nr <= 0)

#228 continue;

This code is used to poll several Sockets for event processing.

 

#229

#230 if (ufds [2]. revents = POLLIN ){

#231/* we got a SIGCHLD-reap and restart as needed */

#232 read (signal_recv_fd, tmp, sizeof (tmp ));

#233 while (! Wait_for_one_process (0 ))

#234;

#235 continue;

#236}

This code is used to process the communication between sub-processes and delete any exited or killed processes. In this way, the system is more robust and fault-tolerant.

 

 

#237

#238 if (ufds [0]. revents = POLLIN)

#239 handle_device_fd (device_fd );

This code is used to handle device events.

 

#240

#241 if (ufds [1]. revents = POLLIN)

#242 handle_property_set_fd (property_set_fd );

This code is used to process Attribute Service events.

 

#243 if (ufds [3]. revents = POLLIN)

#244 handle_keychord (keychord_fd );

This code is a combination of buttons in debugging mode.

 

#245}

#246

#247 return 0;

#248}

#249

 

The main process of the init process has been analyzed here, and other functions will be detailed later.

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.