Application of thread pool technology in street lamp monitoring software

As the infrastructure of modern cities, street lamps play an important role in the daily operation of the city and people's lives. The advanced level of the street lamp system marks the modernization level of a city. The street lamp control system can timely and accurately count the operation and lighting conditions of the street lamp equipment, and send the alarm signal of the street lamp failure or line disconnection to the monitoring center to remotely manage and set the lighting time strategy and dimming rules to achieve reasonable lighting. Lights and on-demand lighting, which can realize the real five-way remote control (telemetry, remote control, remote signaling, remote adjustment, remote viewing). The communication server is an important part of the streetlight monitoring system, responsible for monitoring operations. The client and multiple remote streetlight centralized controllers on both sides of the road perform data communication and data processing. The communication server must be able to provide stable communication services for a large number of monitoring terminal software and street lamp centralized controllers for a long time.

Street lamp system structure diagram In the general concurrent server architecture, a separate thread waits for the client's connection request. When a request arrives, the thread creates a new service thread for processing. After the new thread is created, the main thread returns to the main thread. Waiting for the request status. But in the face of a large number of clients connected to the entire system, the communication server fixed the IP address and provided two port numbers. The communication server communicates with the street lamp centralized controller through the Internet/GPRS network, receives the real-time running status of the street lamp system, stores it in the database, and forwards it to the user monitoring terminal if necessary, and the communication server connects to the user client through the Internet network to receive its control. Command and forward to the streetlight centralized controller.

2C/S communication model and thread pool working principle The network communication mode between the management center and the server and the streetlight centralized controller and server adopts the common C/S mode, that is, the client/server communication mode. In the C/S structure, the server program usually listens to the client's request at a fixed address. The client and the server establish a data transmission through the TCP protocol. The server process is usually in a "sleep" state until the client issues a connection to the server. Request to "wake up" it. At this point, the service thread "wakes up" and reacts appropriately to the client's request. The client always actively requests to initiate communication, and the server waits for passive communication. The process of this request/response is as shown.

A thread pool is a means of managing a certain number of threads. The number of threads in the thread pool is determined by the configuration information of the runtime machine capacity load and the dynamic information.

The basic idea of ​​the thread pool is to open some threads in memory at the beginning of the program, form a pre-derived thread pool, and create a task queue. When a new client request arrives, the newly connected request task is first delivered. Go to the task queue and select an idle thread from the "thread pool" to request service for the new client. After the service is completed, the thread does not exit but enters the idle thread pool. Reduces the overhead of thread object creation and destruction by reusing existing thread objects for multiple tasks. When the client requests, the thread object already exists, which can improve the response time of the request, thereby improving the system service process as follows: binding the local service well-known port.

Create multiple service threads with the listener socket as the parameter, and the main thread sleeps.

The process of the monthly thread is as follows: accept the foreign connection request, the accept function returns the service socket.

Handle the client service request, close the service socket, and return to step (1).

3 server-side software design and implementation 3.1 month server software design ideas in the server program mainly includes two threads, the main thread and the worker thread, the main thread is mainly responsible for listening to the client connection, after receiving a new connection , the new socket is arranged to the worker thread for processing. First create a number of parallel worker threads, typically the number of CPUs, which serve the upcoming client connection. When there is a new service connection request, a worker thread is taken to serve it. If there is no idle worker thread, the new socket connection is added to the task queue. The queue is FIFO. (FIFO) strategy to ensure fair access to connection requests that fail to receive timely service. In addition, the first-in-first-out strategy can reduce the number of CPU switching between different threads and reduce the system overhead caused by thread context switching.

The program uses the following CONNCTX structure to record the information of each client socket, and uses the THREADOB structure to record the information of each worker thread. Their relationship is as shown.

Each time a new connection is received, a structure is created for this new connection and the internal members of the structure are initialized. When the connection is closed or an error occurs, the memory occupied by the client connection corresponding to the CONNCTX structure object is released, so as to avoid memory leakage.

The performance of the handle.

A simple thread pool model-based server program stream creates a THREADOB structure for the thread and initializes the members of the structure. When the worker thread is closed, it releases the corresponding THREADOB. The memory space occupied by the structure object, and a gpThi'eadList will be defined to point to the header of the thread object list. Tvpedefstruct number of socket object list header end of the list of objects / / pointing to the next THREADOB object to form a relationship between the table thread object and the socket object The main thread program mainly creates a listening socket, initializes the global Variables, create thread pools, add new incoming client connections to the client's connection list, and wait for idle worker threads to process. The main frame code is as follows: the declaration of the variable and its initialization // create the listening socket // bind the local address to the listening socket // handle the client's connection request while (TRUE) / / loop processing all pending Connection request // Arrange a socket object to an idle worker thread. After the thread runs, obtain a pointer to the thread object, enter an infinite loop and wait on the event object recorded in the events array to process the network event, the worker thread. The framework code is as follows: the processing of network events // information processing and the simulation test thread pool model of the server software are paid for multi-threading. The server has a faster response to connection requests from large concurrent clients. Test the response speed of this server-side software based on thread pool technology for r. Written multi-threaded server software and client software that can continuously initiate concurrent connections to the server, do the following simulation stress test: the server hardware environment is Intel) 2DuoCPU, 2.93GHz, 2G memory; server respectively 7 based on the thread pool The server-side software of technology and multi-line technology analyzes the server-side software by analyzing the physical memory usage of each of them and the success rate of the client's primary connection. The specific test results are shown in the table: Table 1 server software test comparison server software version thread pool module M multi-thread model client number physical memory currency / M client one connection success rate /% can be seen from Table I. The multi-line technology is waiting for the connection request of the client P terminal by ten pre-planning lines, and its client connection is obviously higher than ten lines. H is more with the client. The client-side connection rate of the multi-line model is declining, while the thread pool inversion is relatively stable. In addition, the thread pool model reduces the number of CPU switching between thread contexts. The multi-threaded pool model requires a large number of new and destroyed threads to be created when a large number of new client connections are made. Therefore, the thread pool model has less physical memory footprint than the multithreaded model. More can save system resources 2008 environment for the development environment, 5 conclusions of thread pool technology. It can effectively solve the problem of concurrent connection between the server and a large number of clients, and minimize the system consumption caused by the creation and destruction of the T thread. Can significantly improve the stability of the server-side software and the rapid response to the client-initiated concurrent connection. This article gives the thread pool technology in the server-side software design ideas and the human body framework implementation code, and H. through and The multi-line model was tested to prove the superiority of the thread pool model.

6Thanks to the Zhejiang Science and Technology Plan Item B) for support and thanks to the support of the Jiashan County Science and Technology Bureau.

Sex Toy Vibration Motor voltage is lower than 6 v, small size, shaking force is strong, the price is cheap. Concrete can be customized according to the requirements of various parameters of the Vibration Motor!


Copper
tungsten steel material
plate material
Sex Toy Vibration Motor
Sex Toy Vibration Motor
Sex Toy Vibration Motor

Vibration of the motor head material, copper, tungsten steel material, plate material, place head motor with different material, different vibration strength, the unit price is different


Operating temperature range:

Sex Toy Vibration Motor should be used at a temperature of -10~60℃.

The figures stated in the catalog specifications are based on use at  ordinary room temperature catalog specifications re based on use at ordinary room temperature  (approximately20~25℃.

If a Micro Vibration Motor For Sex Toy is used outside the prescribed temperature range,the grease on the gearhead area will become unable to function normally and the motor will become unable to start.Depending on the temperature conditions ,it may be possible to deal with them by changing the grease of the motor's parts.Please feel free to consult with us about this.


Storage temperature range:

Sex Toy Vibration Motor should be stored ta a temperature of -15~65℃.

In case of storage outside this range,the grease on the gearhead area will become unable to function normally and the motor will become unable to start.


Service life:

The longevity of Micro Vibration Motor For Sex Toy is greatly affected by the load conditions , the mode of operation,the environment of use ,etc.Therefore,it is necessary to check the conditions under which the product will actually be used .The following conditions will have a negative effect on longevity.Please consult with us should any of them apply.


●Use with a load that exceeds the rated torque

●Frequent starting

●Momentary reversals of turning direction

●Impact loads

●Long-term continuous operation

●Forced turning using the output shaft

●Use in which the permitted overhang load or the permitted thrust load is exceeded

●A pulse drive ,e.g.,a short break,counter electromotive force,PWM control

●Use of a voltage that is nonstandard as regards the rated voltage

●Use outside the prescribed temperature or relative-humidity range,or in a special environment.

●Please consult with us about these or any other conditions of use that may apply,so that we can be sure that you select the most appropriate model.


when it come to volume production,we're a major player as well .each month,we rurn out  600000 units,all of which are compliant with the rohs directive.Have any questions or special needed, please contact us, we have the engineer group and best sales department to service to you Looking forward to your inquiry. Welcome to our factory.

vibration motor

Sex Toy Vibration Motor

Sex Toy Vibration Motor,Micro Vibration Motor For Sex Toy,Dc Sex Toy Vibration Motor,12V Motor For Sex Toy Vibrator

Shenzhen Shunchang Motor Co., LTD. , https://www.scgearmotor.com

Posted on