System service--daemon in Linux

Source: Internet
Author: User

Simply put, the system must provide some services (both the system itself and the network) for certain functions, which are called service. However, service delivery always requires the operation of the program! Otherwise how to run it? So we're going to call him daemon when we get this service procedure. For example, the process of achieving a cyclic routine work scheduling service is Crond this daemon! That's easier to understand!

In general, when we are fully booted into the Linux host in text mode or graphic mode (non-single maintenance mode), the system has provided us with a lot of services! Including print services, job scheduling services, mail management services, and so on, how are these services started? What are their work patterns? Let's talk about it at the bottom.

First, the main classification of daemon:

According to the start-up mode and management of daemon are divided into 2 categories: one is the stand alone can be launched independently, the other is a unified management service through Super daemon.

1. Stand alone: This daemon can start the service on its own.

In the literal sense, stand alone is the meaning of "independent start". This type of daemon can be started on its own without having to be managed by other mechanisms, and it consumes memory and system resources after daemon is started and loaded into memory. The biggest advantage is that, because there is persistent in-memory service,stand alone's daemon response is faster when the client's requirements occur. Common stand alone daemon have WWW daemon (httpd), FTP Daemon (VSFTPD), and so on.

2. Super Daemon: Unified Management Service by a super service

This type of service is initiated by a unified daemon that is responsible for invoking the service! This special daemon is called Super Daemon. The early Super Daemon was inetd, which was later replaced by XINETD. The interesting thing about this mechanism is that when there is no client requirement, the service is not started, and when there is a request from the client, Super Daemon wakes the corresponding service. When the client's request is over, the service that is awakened also shuts down and frees the system resources.

The benefits of this mechanism are: (1) because Super Daemon is responsible for waking up services, Super Daemon can have a security control mechanism, which is similar to the function of network firewall! (2) Because the service is closed after the client's online end, it does not always occupy system resources. But what are the drawbacks? Because there is a client online to wake up the service, and the service load into memory time need to take into account, so the response time of the service will be more slow! Common Super Daemon Managed services such as Telnet this is the thing!

As shown above, Super daemon is resident in memory, program 1, 2, and 3 are programs that start some services (not started). When there are client requirements, Super Daemon will trigger the relevant program to load into the daemon and exist in memory, at this time, the client's requirements will be Super Daemon Guide Daemon 1 to achieve online! When the client's request is over, Daemon 1 will be removed, and the online line in the diagram will be interrupted!

3. Super-daemon Multithreading and Single thread

Multi-threaded Multithreading: Super-daemon distributed to multiple backgrounds daemon

single-threaded Single thread: Queued processing by Super-daemon one by one.

Ii. Types of daemon work patterns:

If the daemon provides the service of the working state to differentiate, but also can be divided into two categories of daemon, respectively:

    • Signal-control
      This daemon is managed through the signal, as long as any client needs to come in, he will immediately start to deal with! For example, the printer's service (CUPSD).

    • Interval-control
      This daemon is mainly "to run a job every once in a while", so what you have to do is specify the time and work that the service will take in the configuration file, and the service will finish the work at the specified time. The ATD and Crond that we mentioned in chapter 16th belong to this type of daemon. (Detects configuration files per minute)

In addition, if you are interested in the development process, then you can check the "Man 3 daemon" to see the system for daemon detailed instructions! ^_^.

Iii. Nomenclature of Daemon

Every developer of a service has a special story when they develop their services. However, after the names of these services have been created, when they are hung on Linux, usually after the service name is added a D, such as the creation of a routine command at, and Cron, the two services, his program file name will be taken as ATD and Crond, this d represents the Dae Mon's meaning. Therefore, we use the PS and top to observe the program, will find a lot of {Xxx}d program, hehe! Usually that's some daemon program!

System service--daemon in Linux

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.