Your SlideShare is downloading. ×
0
Process control daemon
Process control daemon
Process control daemon
Process control daemon
Process control daemon
Process control daemon
Process control daemon
Process control daemon
Process control daemon
Process control daemon
Process control daemon
Process control daemon
Process control daemon
Process control daemon
Process control daemon
Process control daemon
Process control daemon
Process control daemon
Process control daemon
Process control daemon
Process control daemon
Process control daemon
Process control daemon
Process control daemon
Process control daemon
Process control daemon
Process control daemon
Process control daemon
Process control daemon
Process control daemon
Process control daemon
Process control daemon
Process control daemon
Process control daemon
Process control daemon
Process control daemon
Process control daemon
Process control daemon
Process control daemon
Process control daemon
Process control daemon
Process control daemon
Process control daemon
Process control daemon
Process control daemon
Process control daemon
Process control daemon
Process control daemon
Process control daemon
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Process control daemon

9,380

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
9,380
On Slideshare
0
From Embeds
0
Number of Embeds
12
Actions
Shares
0
Downloads
39
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Process Control DaemonFor Embedded Linux Platforms<br />Speaker: Hai Shalom<br />rt-embedded.com/pcd<br />
  • 2. Background review: What were the reasons that led to the development of PCD.<br />PCD project review: Features and high level overview of the project.<br />Live demonstration.<br />Q &amp; A.<br />Agenda<br />
  • 3. Does your product have a process controller?<br />Does your product automatically recover after a crash?<br />Do you think your product’s boot time is fast enough?<br />Are you using methods other than printf to debug a crashed application?<br />Are you familiar with all the processes which are running in your product and their dependencies?<br />Some questions<br />
  • 4. Most of you probably answered “No” to at least one question.<br />People who answered “Yes” to all questions are probably using PCD already!<br />Let’s review some facts about Embedded Linux based products…<br />What were your answers?<br />
  • 5. Done by scripts (rcS, rc.*). These are great, but might be:<br /><ul><li>Not optimal for embedded / not deterministic:
  • 6. Limited ways to synchronize depended processes(delay).
  • 7. Limited ways to verify successful start of a process
  • 8. No error checking (usually).
  • 9. No formal way to define dependencies.
  • 10. Difficult to start processes in parallel.
  • 11. Not trivial to understand, maintain and extend:
  • 12. Require additional shell scripting expertise.
  • 13. Tend to be long and unreadable.
  • 14. Plenty of commented code, old remarks, different code styles.</li></ul>System start up<br />
  • 15. Done by scripts (rcS, rc.*). These are great, but might be:<br /><ul><li>Not optimal for embedded / not deterministic:
  • 16. Limited ways to synchronize depended processes (delay).
  • 17. Limited ways to verify successful start of a process
  • 18. No error checking (usually).
  • 19. No formal way to define dependencies.
  • 20. Difficult to start processes in parallel.
  • 21. Not trivial to understand, maintain and extend:
  • 22. Require additional shell scripting expertise.
  • 23. Tend to be long and unreadable.
  • 24. Plenty of commented code, old remarks, different code styles.</li></ul>System start up<br />Looks familiar?<br />
  • 25. A crashed program just terminates, usually after printing “Segmentation Fault”.<br /><ul><li>Now what?
  • 26. Where is the debug information?
  • 27. Kernel crashes are assumed to be handled by the system’s watchdog.</li></ul>Signal Handlers not always implemented correctly.<br /><ul><li>Unsafe to use printf, and many other functions.</li></ul>The system remains unstable and unusable. <br /><ul><li>End user must power-cycle (again?).</li></ul>Crash handling and recovery<br />
  • 28. A crashed program just terminates, usually after printing “Segmentation Fault”.<br /><ul><li>Now what?
  • 29. Where is the debug information?
  • 30. Kernel crashes are assumed to be handled by the system’s watchdog.</li></ul>Signal Handlers not always implemented correctly.<br /><ul><li>Unsafe to use printf, and many other functions.</li></ul>The system remains unstable and unusable. <br /><ul><li>End user must power-cycle (again?).</li></ul>Crash handling and recovery<br />
  • 31. No central management entity.<br /><ul><li>init is the parent of all processes.</li></ul>Must know process’ pid in order to signal or kill.<br />Each process must manage his own children.<br /><ul><li>Child process inherits his father’s priority.
  • 32. Parents must retrieve child’sexit status, or else we end upwith Zombies…</li></ul>Process management<br />
  • 33. A customer reports a crash in the field or in his lab tests:<br /><ul><li>There is no standard method for generating and collecting remote debug information.
  • 34. When a process abnormally terminates, all its information goes away and no log is saved.
  • 35. You might be on the next flight to the customer’s lab.</li></ul>Field/Remote debugging<br />
  • 36. A great (and free) solution: PCD<br />What is PCD?<br />
  • 37. What is PCD?<br />PCD – Process Control Daemon, is an open source, light-weight system level process manager for Embedded-Linux based products (consumer electronics, network devices, etc).<br />The PCD provides a complementary service for any Embedded Linux driven product. <br />Designed and implemented by Hai Shalom during employment at Texas Instruments for Next-Gen Puma5 Cable chipset.<br />Released to open source as part of his M.Sc. Degree research.<br />PCD is a proven solution that already drives millions of devices in the world.<br />
  • 38. System startup: PCD starts up the system in an efficient, synchronized and deterministic manner.<br />Process management: a centralized entity that controls and monitors all processes, and provides API to manage them. <br />System recovery: Configurable per process recovery action is taken in case of a crash.<br />Debug information: PCD provides a detailed crash log in case of a program error.<br />PCD Features in high-level<br />
  • 39. How does it work?<br />What are the advantages of products with PCD?<br />
  • 40. Rule blocks replace/extend traditional shell scripts.<br />Each rule defines a single process.<br />Rule inter-dependency is well defined.<br />PCD Scripts: Rule blocks<br />Process 1<br />Rule 1<br />PCDScriptFile<br />Process 2<br />Rule 2<br />Process 3<br />Rule 3<br />
  • 41. Very simple and readable syntax.<br />Easy to extend and maintain.<br />Each Rule block is based on the same template and contains the following details:<br /><ul><li>What is the process name and parameters?
  • 42. When to start it (depends on event…)?
  • 43. What is the required priority?
  • 44. What is the completion event?
  • 45. How much time to wait for it to complete?
  • 46. What to do in case of a crash?</li></ul>PCD Scripts: Rule blocks<br />
  • 47. Very simple and readable syntax.<br />Easy to extend and maintain.<br />Each Rule block is based on the same template and contains the following details:<br /><ul><li>What is the process name and parameters?
  • 48. When to start it (depends on event…)?
  • 49. What is the required priority?
  • 50. What is the completion event?
  • 51. How much time to wait for it to complete?
  • 52. What to do in case of a crash?</li></ul>PCD Scripts: Rule blocks<br />
  • 53. Event Driven System Startup<br />Once all rules are parsed, the PCD builds a dependency graph database.<br />PCD starts each rule in the “right” time.<br />PCD continuously monitors the system.<br />PCD<br />Rule<br />Rule<br />Rule<br />Rule<br />Rule<br />Rule<br />Rule<br />Rule<br />Rule<br />Rule<br />Last<br />
  • 54. Right time when a Start eventoccurred:<br /><ul><li>Another rule or set of rules have completed successfully, or;
  • 55. A resource has been created (Network device, file).</li></ul>Completion event when the attached process:<br /><ul><li>Has exited with the correct status, or;
  • 56. Sent a “Process ready” event to the PCD, or;
  • 57. Created a resource, or;
  • 58. Was running for a specified amount of time, or;
  • 59. Was created.
  • 60. A Completion event of one rule could be the Start event of another rule.</li></ul>Event Driven System Startup<br />
  • 61. Dependencies between processes are well defined.<br />Rules are started as soon as their start event comes.<br />No need for non-deterministic delays between starting processes.<br />Rules without inter-dependency are started in parallel.<br />Improve user experience and product reputation (Fast product!)<br />Reduced startup time<br />
  • 62. Enhanced stability and robustness<br />Crash<br />Process<br />Signal<br />PCD<br />Rule<br />Restart<br />Recover<br />Rule<br />Ignore<br />Reboot<br />
  • 63. Enhanced stability and robustness<br />Enhanced monitoring on processes and recovery in case of failure.<br />Each Rule defines what to do in case its process crashes:<br /><ul><li>Restart the process: Usually for non-critical services such as a web server, or processes that can recover by restarting themselves.
  • 64. Reboot the system: In case of a fatal, non-recoverable error.
  • 65. Initiate a recovery rule.
  • 66. Ignore: Similar behavior without PCD.</li></li></ul><li>Enhanced debugging capabilities<br />Crash<br />Signal<br />PCD<br />API<br />Process<br />PCD<br />Rule<br />Prepare and send exception info<br />Detailed <br />Crash<br />Log<br />Log in <br />NVRAM<br />
  • 67. Enhanced debugging capabilities<br />The PCD exception handlers will catch and handle any fault exception (Signals).<br />The PCD will provide useful debug information.<br />The information speeds up the error fixing cycle and improves product robustness.<br />Error logs are saved in non-volatile memory<br /><ul><li>Can be used for offline analysis after a validation cycle in the lab.
  • 68. Can be used for post-mortem analysis of units from the field.</li></li></ul><li>Snapshot taken from an ARM platform.<br />Contains:<br /><ul><li>Signal info
  • 69. Registers
  • 70. Map file
  • 71. Registers pc and lr/ra can be used to trace the bug using addr2line or objdump.</li></ul>Crash log with PCD<br />
  • 72. Process management<br />New Configuration<br />Request to restart Process 2<br />Process 1<br />Process 2<br />Process 2<br />Restart Process 2<br />Rule 1<br />Rule 2<br />PCD<br />Rule 4<br />Rule 3<br />User input: Disable <br />something<br />Process 3<br />Process 4<br />Request to terminateProcess 4<br />TerminateProcess 4<br />
  • 73. Process management with PCD API:<br /><ul><li>Start or terminate a process.
  • 74. Send a “process ready” event.
  • 75. Signal a process.
  • 76. Register to exception handlers.
  • 77. Reboot the system (with logged a reason).</li></ul>The PCD API is available by linking with the PCD library.<br />Process management<br />
  • 78. What is the order that the processes are started?<br />What is each process dependency?<br />PCDcan generate dependency graphs for visual representation of all the rules and their dependencies.<br />Visibility provides an excellent means to examine and understand the dependencies between each rule in the system, and fix them in case of mistakes.<br />Dependency graph generation<br />
  • 79. PCD is architecture agnostic, except for the crash log code that displays register details.<br />Up to date, the following platforms are supported:<br /><ul><li>ARM (primary development target).
  • 80. MIPS (secondary development target).
  • 81. x86
  • 82. x64
  • 83. For other platforms, the crash log will not include register details.
  • 84. Last two architectures allow running a PCD driven system in any development PC running Linux.</li></ul>Supported architectures<br />
  • 85. PCD is a light-weight process controller for embedded platforms.<br />Here are its modest memory requirements:<br /><ul><li>PCD Code: 28KB
  • 86. PCD Data section: 4KB
  • 87. PCD Heap: 36KB (Typical).
  • 88. PCD Stack (Watermark): 84KB (Typical).</li></ul>Memory Requirements<br />
  • 89. The PCD Project is an Open-Source project.<br />The PCD project is licensed under the GNU Lesser General Public License version 2.1, as published by the Free Software Foundation.<br />Its license allows linking proprietary software without any license contamination.<br />To view a copy of this license, visithttp://www.gnu.org/licenses/lgpl-2.1.html#SEC1<br />Licensing<br />
  • 90. PCD contribution to product success<br />PCD improved the Puma5 products in various aspects:<br /><ul><li>Startup time: The system boots much more quickly comparing to scripts (15 seconds faster).
  • 91. Robustness, availability: Due to the recovery actions, the system is more available and user experience is better.
  • 92. Quality: Detailed crash logs pointed out bugs, reduced fix time, enabled remote and offline analysis.
  • 93. Customers found it very useful:
  • 94. Added new rule blocks with their own modifications.</li></li></ul><li>PCD Home page (Hai’s Real-Time Embedded blog): http://www.rt-embedded.com/pcd<br />Project management and source code at SourceForge: http://sourceforge.net/projects/pcd/<br />PCD Documentation and user guides (Yes! There is some): http://www.rt-embedded.com/blog/pcd-process-control-daemon/pcd-documentation/<br />PCD support forum: http://sourceforge.net/projects/pcd/support<br />New software engineers are welcomed to join the project and contribute.<br />PCD Resources<br />
  • 95. Questions and Answers<br />Hai, fixing a bug<br />
  • 96. Wrap Up<br />
  • 97. System startup: PCD starts up the system in an efficient, synchronized and deterministic manner.<br />Process management: a centralized entity that controls and monitors all processes, and provides API to manage them. <br />System recovery: Configurable per process recovery action is taken in case of a crash.<br />Debug information: PCD provides a detailed crash log in case of a program error.<br />PCD can make your product a better product!<br />PCD Features in high-level<br />
  • 98. Thank you!<br />Hai Shalom<br />
  • 99. Backup slides<br />
  • 100. PCD High level technical info<br />
  • 101. The PCD API provides an easy interface to request various services from the PCD:<br />Start or terminate a process.<br />Send a “process ready” event.<br />Signal a process.<br />Register to PCD default exception handlers.<br />Reboot the system (with logged a reason).<br />The PCD API is available by linking with the PCD library.<br />Standard API for PCD services<br />
  • 102. PCD Exception handler<br />Every program can register to PCD’s exception handlers.<br />The PCD performs as a “crash daemon” which listens on a dedicated socket.<br />The exception handler collects debug information and sends it to the PCD using only “Safe functions”.<br />The PCD formats the data, displays it on the console and logs it in the non-volatile storage.<br />
  • 103. The PCD design features various loosely coupled software modules:<br />Main: Performs the initializations and the main loop.<br />Rule Parser: Reads and parses the textual rules.<br />Rules DB: Stores all the rules as binary records.<br />Process: Starts, stops and monitors the processes<br />Timer: Provides the ticks for the pcd.<br />Condition check: Checks if a condition is satisfied.<br />Failure action: Performs failure/recovery actions.<br />Exception: Implements the detailed exception handlers.<br />API: The PCD API interface (As a separate library).<br />PCD Software modules<br />
  • 104. PCD Software modules block diagram<br />PARSER<br />RULES<br />DB<br />Textual configuration file with rules<br />Add Rule<br />Rule Info<br />OK/Fail<br />Parse Rules File<br />OK/Fail<br />Activate Rules<br />MAIN<br />PCDAPI<br />Check Messages<br />Application<br />Activate /<br />Stop<br />IPC<br />Enqueue /<br />Dequeue<br />Rule<br />Tick<br />Crashed<br />Iterate<br />Check<br />Condition<br />Enqueue<br />Rule<br />TIMER<br />PROCESS CONTRL<br />CONDITIONCHECK<br />EXCEPTION HANDLER<br />OK / NOK<br />Enqueue Process<br />Spawn / Signal /Monitor<br />Stopped / Signaled / Exited<br />Activate failure action<br />Activate Rule<br />FAILUREACTION<br />Process<br />Activate failure action<br />
  • 105. A textual file, similar to shell script syntax.<br />Contains a list of “Rule Blocks”. <br />A Rule block is defined per process.<br />Scripts can be extended by including other scripts.<br />dividing dedicated scripts per each logical or functional sub-system in the system.<br />PCD Rules Script<br />
  • 106. Rules and Processes block diagram<br />PROCESS CONTROL<br />PARSER<br />RULESDB<br />Started, Stopped, Monitored<br />Add Rule<br />Read<br />Rule<br />Process<br />Associated<br />PCD Script<br />Rule<br />Rule<br />Rule<br />…<br />Rule<br />Depends<br />Rule<br />Process<br />Associated<br />Started, Stopped, Monitored<br />Depends<br />Rule<br />Process<br />Associated<br />Started, Stopped, Monitored<br />
  • 107. PCD Rules Script Syntax<br />
  • 108. The PCD provides a parser which provides an easy way to verify that your PCD scripts do not contain syntax errors, similarly to compilation process.<br />The parser allows to fix the configuration files on the host, without the need to run them on the target, and rebuilding an image in case of an error.<br />Syntax Checking<br />
  • 109. No purchase costs or royalty fees.<br />Source code is fully available.<br />High quality code due to extensive exposure.<br />LGPL allows linking proprietary code with PCD.<br />Continuous development and bug fixes.<br />Need a new feature?<br />Either request it in the project tracker system<br />Or join the PCD community and develop it, so other could also enjoy your productivity.<br />PCD - Open Source Benefits<br />
  • 110. Support more platforms.<br />Watchdog/Keep alive mechanism.<br />Kernel monitoring agent/module.<br />Rule enhancements:<br />Affinity<br />Resource limitation (CPU, Heap, Stack, Fork Bombs..)<br />Current working directory<br />Others…<br />PCD – Wish list (Future Features)<br />

×