[go: up one dir, main page]

CN112286687B - Resource processing method and device - Google Patents

Resource processing method and device Download PDF

Info

Publication number
CN112286687B
CN112286687B CN202011194968.4A CN202011194968A CN112286687B CN 112286687 B CN112286687 B CN 112286687B CN 202011194968 A CN202011194968 A CN 202011194968A CN 112286687 B CN112286687 B CN 112286687B
Authority
CN
China
Prior art keywords
thread
resource pool
resources
exclusive
shared
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202011194968.4A
Other languages
Chinese (zh)
Other versions
CN112286687A (en
Inventor
刘兴
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Sogou Technology Development Co Ltd
Original Assignee
Beijing Sogou Technology Development Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Sogou Technology Development Co Ltd filed Critical Beijing Sogou Technology Development Co Ltd
Priority to CN202011194968.4A priority Critical patent/CN112286687B/en
Publication of CN112286687A publication Critical patent/CN112286687A/en
Application granted granted Critical
Publication of CN112286687B publication Critical patent/CN112286687B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/50Indexing scheme relating to G06F9/50
    • G06F2209/503Resource availability

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Debugging And Monitoring (AREA)

Abstract

本申请公开了一种资源处理方法,在该方法中,各个线程可以具备对应的独占资源池,以第一线程为例,第一线程可以具备第一线程对应的独占资源池,第一线程对应的独占资源池,仅用于为第一线程提供资源,而不为其它线程提供资源。正是因为如此,除了第一线程之外,其它线程不会从第一线程对应的独占资源池中获取资源,换言之,第一线程对应的独占资源池不会如传统技术中的共享资源池那样被其它线程锁定。当需要运行第一线程时,可以直接从第一线程对应的独占资源池中获取资源,从而利用所获取的资源运行第一线程。由此可见,利用本申请实施例的方案,可以提升并发性。

The present application discloses a resource processing method, in which each thread may have a corresponding exclusive resource pool. Taking the first thread as an example, the first thread may have an exclusive resource pool corresponding to the first thread. The exclusive resource pool corresponding to the first thread is only used to provide resources for the first thread, but not for other threads. Precisely because of this, except for the first thread, other threads will not obtain resources from the exclusive resource pool corresponding to the first thread. In other words, the exclusive resource pool corresponding to the first thread will not be locked by other threads like the shared resource pool in the traditional technology. When it is necessary to run the first thread, resources can be directly obtained from the exclusive resource pool corresponding to the first thread, so as to run the first thread using the obtained resources. It can be seen that the concurrency can be improved by using the scheme of the embodiment of the present application.

Description

Resource processing method and device
Technical Field
The present application relates to the field of data processing, and in particular, to a method and apparatus for processing resources.
Background
Pooling techniques may be utilized to enhance the performance of a computer. The pooling technology refers to the technology that resources are created in advance and put into a resource pool, and the resources are directly obtained from the resource pool when the resources are needed to be used, so that the consumption of the created resources is avoided, and the efficiency is improved.
Currently, pooling techniques can be applied to multithreaded programming. I.e., multiple threads may each acquire resources from the resource pool. However, at most only one thread can use the resources in the resource pool at the same time, so that a plurality of threads cannot run simultaneously, and concurrency is reduced.
Disclosure of Invention
The application aims to solve the technical problem of improving concurrency when a pooling technology is applied to multi-thread programming, and provides a resource processing method and device.
In a first aspect, an embodiment of the present application provides a resource processing method, where the method includes:
Acquiring resources from an exclusive resource pool corresponding to a first thread, wherein the exclusive resource pool corresponding to the first thread is used for providing resources for the first thread;
and running the first thread by using the acquired resources.
Optionally, before the obtaining the resource from the exclusive resource pool corresponding to the first thread, the method further includes:
and determining that resources exist in an exclusive resource pool corresponding to the first thread.
Optionally, the method further comprises:
Under the condition that no resource exists in the exclusive resource pool corresponding to the first thread, locking a shared resource pool and acquiring the resource from the shared resource pool, wherein:
and the resources in the shared resource pool are used for providing resources for a plurality of threads, wherein the threads comprise the first thread.
Optionally, before determining that the resource does not exist in the exclusive resource pool corresponding to the first thread, the locking the shared resource pool and acquiring the resource from the shared resource pool further includes:
determining that resources exist in the shared resource pool.
Optionally, the method further comprises:
creating a resource for the first thread if it is determined that no resource exists in the shared resource pool;
running the first thread by using the acquired resources, including:
And running the first thread by using the created resources.
Optionally, the method further comprises:
And after the first thread is operated, if the resources included in the exclusive resource pool corresponding to the first thread are smaller than or equal to a first threshold, releasing the acquired resources into the exclusive resource pool corresponding to the first thread.
Optionally, the method further comprises:
after the first thread is operated, if the resources included in the exclusive resource pool corresponding to the first thread are greater than a first threshold, locking a shared resource pool and releasing the acquired resources into the shared resource pool, wherein:
And the resources in the shared resources are used for providing resources for a plurality of threads, and the threads comprise the first thread.
In a second aspect, an embodiment of the present application provides a resource processing apparatus, including:
an obtaining unit, configured to obtain resources from an exclusive resource pool corresponding to a first thread, where the exclusive resource pool corresponding to the first thread is used to provide resources for the first thread;
And the running unit is used for running the first thread by using the acquired resources.
Optionally, the apparatus further includes:
And the first determining unit is used for determining that the resources exist in the exclusive resource pool corresponding to the first thread before the resources are acquired from the exclusive resource pool corresponding to the first thread.
Optionally, the apparatus further includes:
the locking unit is used for locking the shared resource pool and acquiring the resources from the shared resource pool under the condition that the resources do not exist in the exclusive resource pool corresponding to the first thread, wherein:
and the resources in the shared resource pool are used for providing resources for a plurality of threads, wherein the threads comprise the first thread.
Optionally, the apparatus further includes:
And the second determining unit is used for determining that the resources exist in the shared resource pool before the shared resource pool is locked and the resources are acquired from the shared resource pool.
Optionally, the apparatus further includes:
a creating unit, configured to create a resource for the first thread if it is determined that no resource exists in the shared resource pool;
The operation unit is used for:
And running the first thread by using the created resources.
Optionally, the apparatus further includes:
And the first releasing unit is used for releasing the acquired resources into the exclusive resource pool corresponding to the first thread if the resources included in the exclusive resource pool corresponding to the first thread are smaller than or equal to a first threshold after the first thread is operated.
Optionally, the apparatus further includes:
And a second releasing unit, configured to lock a shared resource pool and release the acquired resource to the shared resource pool if the resource included in the exclusive resource pool corresponding to the first thread is greater than a first threshold after the operation of the first thread is finished, where:
And the resources in the shared resources are used for providing resources for a plurality of threads, and the threads comprise the first thread.
In a third aspect, embodiments of the present application provide a resource processing device including a memory, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by one or more processors, the one or more programs comprising instructions for:
Acquiring resources from an exclusive resource pool corresponding to a first thread, wherein the exclusive resource pool corresponding to the first thread is used for providing resources for the first thread;
and running the first thread by using the acquired resources.
Optionally, before the obtaining the resource from the exclusive resource pool corresponding to the first thread, the method further includes:
and determining that resources exist in an exclusive resource pool corresponding to the first thread.
Optionally, the operations further include:
Under the condition that no resource exists in the exclusive resource pool corresponding to the first thread, locking a shared resource pool and acquiring the resource from the shared resource pool, wherein:
and the resources in the shared resource pool are used for providing resources for a plurality of threads, wherein the threads comprise the first thread.
Optionally, before determining that the resource does not exist in the exclusive resource pool corresponding to the first thread, the locking the shared resource pool and acquiring the resource from the shared resource pool further includes:
determining that resources exist in the shared resource pool.
Optionally, the operations further include:
creating a resource for the first thread if it is determined that no resource exists in the shared resource pool;
running the first thread by using the acquired resources, including:
And running the first thread by using the created resources.
Optionally, the operations further include:
And after the first thread is operated, if the resources included in the exclusive resource pool corresponding to the first thread are smaller than or equal to a first threshold, releasing the acquired resources into the exclusive resource pool corresponding to the first thread.
Optionally, the operations further include:
after the first thread is operated, if the resources included in the exclusive resource pool corresponding to the first thread are greater than a first threshold, locking a shared resource pool and releasing the acquired resources into the shared resource pool, wherein:
And the resources in the shared resources are used for providing resources for a plurality of threads, and the threads comprise the first thread.
In a fourth aspect, embodiments of the present application provide a computer-readable medium having instructions stored thereon, which when executed by one or more processors, cause an apparatus to perform the method of any of the first aspects above.
Compared with the prior art, the embodiment of the application has the following advantages:
The embodiment of the application provides a resource processing method, in the method, a shared resource pool is not shared by a plurality of threads as in the prior art, and if a first thread needs to be operated, resources can be acquired from the shared resource pool only under the condition that the shared resource pool is not locked by other threads, so that the first thread is operated. In the present application, each thread may have a corresponding exclusive resource pool, for example, a first thread may have an exclusive resource pool corresponding to the first thread, where the exclusive resource pool corresponding to the first thread is only used to provide resources for the first thread, but not for other threads. Because of this, other threads than the first thread do not acquire resources from the exclusive resource pool corresponding to the first thread, in other words, the exclusive resource pool corresponding to the first thread is not locked by other threads as in the shared resource pool in the conventional art. When the first thread needs to be operated, the resources can be directly obtained from the exclusive resource pool corresponding to the first thread, so that the first thread is operated by utilizing the obtained resources. Therefore, by utilizing the scheme of the embodiment of the application, concurrency can be improved.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings that are required to be used in the embodiments or the description of the prior art will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments described in the present application, and other drawings may be obtained according to the drawings without inventive effort to those skilled in the art.
FIG. 1 is a schematic flow chart of a resource processing method according to an embodiment of the present application;
fig. 2 is a schematic structural diagram of a resource processing device according to an embodiment of the present application;
fig. 3 is a schematic structural diagram of a client according to an embodiment of the present application;
Fig. 4 is a schematic structural diagram of a server according to an embodiment of the present application.
Detailed Description
In order to make the present application better understood by those skilled in the art, the following description will clearly and completely describe the technical solutions in the embodiments of the present application with reference to the accompanying drawings, and it is apparent that the described embodiments are only some embodiments of the present application, not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to be within the scope of the application.
The inventors of the present application have found that pooling techniques can be applied to multithreaded programming. In one example, resources may be created in advance and placed into a shared resource pool. The shared resource pool may be used to provide resources for multiple threads. Currently, when a plurality of threads acquire resources from a shared resource pool, at most only one thread can use the resources in the resource pool at the same time. Specifically, when thread 1 needs to acquire a resource from a shared resource pool, thread 1 may first lock the shared resource pool (may also be referred to as "locking the shared resource Chi Jiasuo"), then acquire a resource from the shared resource pool to run thread 1, and after thread 1 finishes running, may release the resource into the shared resource pool, and then unlock the shared resource pool. When the shared resource pool is in a locked state, other threads cannot acquire resources from the shared resource pool. In other words, if the shared resource pool is locked by thread 1, thread 2 cannot acquire resources from the shared resource pool, and thread 2 must wait until thread 1 releases the lock on the shared resource pool to acquire resources from the shared resource pool to run thread 2. Because of this, multiple threads cannot run simultaneously, reducing concurrency.
In order to solve the above problems, the embodiment of the application provides a resource processing method and device.
Various non-limiting embodiments of the present application are described in detail below with reference to the attached drawing figures.
Exemplary method
Referring to fig. 1, the flow chart of a resource processing method according to an embodiment of the present application is shown.
The resource processing method provided by the embodiment of the application may be executed by a controller or a processor having a data processing function, or may be executed by a device including the controller or the processor, and the embodiment of the application is not particularly limited. Wherein the device comprising the controller or processor includes, but is not limited to, a terminal device and a server.
In this embodiment, the resource processing method shown in fig. 1 may include, for example, the following steps S101 to S102.
S101, acquiring resources from an exclusive resource pool corresponding to a first thread, wherein the exclusive resource pool corresponding to the first thread is used for providing resources for the first thread.
In the embodiment of the application, an exclusive resource pool can be respectively created for each thread in the initialization stage of the service. Wherein a service may comprise one or more businesses that may run in a particular thread.
The first thread is any one of the threads. The exclusive resource pool corresponding to the first thread is only used for providing resources for the first thread, and not providing resources for other threads. In the embodiment of the present application, the resources in the exclusive resource pool corresponding to the first thread may include one or more of a thread pool, a memory pool, and a connection pool, for example. The thread pool, memory pool, and connection pool are not described in detail herein.
In the embodiment of the application, when the first thread is needed to be utilized to run the service, the resources can be obtained from the exclusive resource pool corresponding to the first thread.
S102, running the first thread by using the acquired resources.
After obtaining the resources from the exclusive resource pool corresponding to the first thread, the first thread can be operated by using the resources obtained from the exclusive resource pool corresponding to the first thread, so as to realize the processing of a certain service.
It will be appreciated from the above description that, due to the exclusive resource pool corresponding to the first thread, only resources are provided for the first thread, and resources are not provided for other threads. Thus, other threads, except the first thread, do not acquire resources from the exclusive resource pool corresponding to the first thread, in other words, the exclusive resource pool corresponding to the first thread is not locked by other threads as in the conventional shared resource pool. When the first thread needs to be operated, the resources can be directly obtained from the exclusive resource pool corresponding to the first thread, so that the first thread is operated by utilizing the obtained resources. Therefore, by utilizing the scheme of the embodiment of the application, concurrency can be improved.
In some scenarios, after the traffic processing is completed, the resources used to process the traffic may be released. During the service processing, there may be multi-thread scheduling, which may cause the resources acquired from the exclusive resource pool of the first thread to be released to the exclusive resource pool of other threads, for example, the second thread, so that the resources in the exclusive resource pool corresponding to the first thread are less and less, and even no resources are available. And the resources in the exclusive resource pool corresponding to the second thread are more and more.
For example, for user login traffic, thread 1, which involves applying a link to verify if the username and password match, and thread 2, which returns the link. When the thread 1 is operated, resources are acquired from an exclusive resource pool corresponding to the thread 1, and the thread operated in a return link is the thread 2, so when the user name and the password are verified to be matched, the resources acquired from the exclusive resource pool of the thread 1 are released to the exclusive resource pool corresponding to the thread 2 when the link is further returned, so that the resources in the exclusive resource pool corresponding to the thread 1 are reduced, and the resources in the exclusive resource pool corresponding to the thread 2 are increased.
Because no resources may be available in the exclusive resource pool corresponding to the first thread as described above, in an example of the embodiment of the present application, it may be further determined whether resources exist in the exclusive resource pool corresponding to the first thread before executing the foregoing S101, and if it is determined that resources exist in the exclusive resource pool corresponding to the first thread, the foregoing S101 and subsequent steps are executed again, so as to implement running the first thread using the resources in the exclusive resource pool of the first thread.
In addition, in order to make the first thread normally run even if there is no resource in the exclusive resource pool corresponding to the first thread. In the embodiment of the application, in addition to creating an exclusive resource pool for each thread, a shared resource pool may be created in the initialization stage of the service, where the shared resource pool is used to provide resources for a plurality of threads, and the plurality of threads includes the first thread. In this way, when there is no resource in the exclusive resource pool corresponding to the first thread, the resource may be acquired from the shared resource pool, and the first thread may be executed using the resource acquired from the shared resource pool. Specifically, before resources are acquired from the shared resource pool, the shared resource pool may be locked first, and then resources are acquired from the shared resource pool.
In some scenarios of embodiments of the present application, there are resources in the shared resource pool during the initialization phase of the service. However, as the service runs, resources may or may not still exist in the shared resource pool. For specific reasons reference is made to the description of the resource release section below, which is not explained in detail here. Therefore, in one implementation manner of the embodiment of the present application, before locking the shared resource pool, it may also be determined whether a resource exists in the shared resource pool, and if it is determined that a resource exists in the shared resource pool, the shared resource pool is locked again, and a resource is acquired from the shared resource pool to run the first thread.
In an example of the embodiment of the present application, if no resource exists in the exclusive resource pool corresponding to the first thread and no resource is included in the shared resource pool, a new resource may be created for the first thread, and the first thread is operated by using the created resource, so that the first thread can operate normally.
In the embodiment of the present application, after the first thread is run, the resources used for running the first thread may be released, that is, the acquired resources mentioned in S102 may be released. In some embodiments, considering that if there is a resource in the exclusive resource pool corresponding to the first thread, concurrency may be improved to the greatest extent, so that when the first thread needs to be run, the resource needs to be acquired from the shared resource pool or re-created, and therefore, after the first thread is run, the resource used for running the first thread may be released to the exclusive resource pool corresponding to the first thread.
It will be appreciated that the resources used by the first thread to run as referred to herein may be obtained from an exclusive resource pool to which the first thread corresponds, may be obtained from a shared resource pool, or may be temporarily created for the first thread. The embodiment of the present application is not particularly limited. Also, even if the resource used for running the first thread is obtained from the shared resource pool, the resource may be released to the exclusive resource pool corresponding to the first thread, so that, with the running of the service, there may be no resource in the shared resource pool.
In other embodiments, it is contemplated that the resources required to run the first thread are typically limited, e.g., do not exceed a first threshold. Therefore, when the original resources in the exclusive resource pool of the first thread have exceeded the first threshold, it is indicated that there are enough resources in the exclusive resource pool corresponding to the first thread to run the first thread, and in this case, in the embodiment of the present application, the resources used for running the first thread may be released to the shared resource pool, so that the shared resource pool may provide resources for other threads, and the problem that the overall resource utilization is low due to too many resources in the resource pool corresponding to the first thread may also be avoided. Specifically, the shared resource pool may be locked, and after the resources used by the first thread are released to the shared resource pool, the shared resource pool may be unlocked.
In other words, in the embodiment of the present application, after the operation of the first thread is finished, if the resources included in the exclusive resource pool corresponding to the first thread are smaller than or equal to the first threshold, the resources used for operating the first thread are released to the exclusive resource pool corresponding to the first thread, so as to improve concurrency to the greatest extent. After the first thread finishes running, if the resources included in the exclusive resource pool corresponding to the first thread are greater than a first threshold, locking a shared resource pool, and releasing the acquired resources into the shared resource pool, so that the shared resource pool can provide resources for other threads.
Exemplary apparatus
Based on the method provided by the above embodiment, the embodiment of the present application further provides a resource processing device, and the device is described below with reference to the accompanying drawings.
Referring to fig. 2, the structure of a resource processing device according to an embodiment of the present application is shown. The apparatus 200 may specifically comprise, for example, an acquisition unit 201 and an operation unit 202.
An obtaining unit 201, configured to obtain a resource from an exclusive resource pool corresponding to a first thread, where the exclusive resource pool corresponding to the first thread is used to provide the resource for the first thread;
And the running unit 202 is configured to run the first thread by using the acquired resource.
In one implementation, the apparatus further comprises:
And the first determining unit is used for determining that the resources exist in the exclusive resource pool corresponding to the first thread before the resources are acquired from the exclusive resource pool corresponding to the first thread.
In one implementation, the apparatus further comprises:
the locking unit is used for locking the shared resource pool and acquiring the resources from the shared resource pool under the condition that the resources do not exist in the exclusive resource pool corresponding to the first thread, wherein:
and the resources in the shared resource pool are used for providing resources for a plurality of threads, wherein the threads comprise the first thread.
In one implementation, the apparatus further comprises:
And the second determining unit is used for determining that the resources exist in the shared resource pool before the shared resource pool is locked and the resources are acquired from the shared resource pool.
In one implementation, the apparatus further comprises:
a creating unit, configured to create a resource for the first thread if it is determined that no resource exists in the shared resource pool;
The operation unit 202 is configured to:
And running the first thread by using the created resources.
In one implementation, the apparatus further comprises:
And the first releasing unit is used for releasing the acquired resources into the exclusive resource pool corresponding to the first thread if the resources included in the exclusive resource pool corresponding to the first thread are smaller than or equal to a first threshold after the first thread is operated.
In one implementation, the apparatus further comprises:
And a second releasing unit, configured to lock a shared resource pool and release the acquired resource to the shared resource pool if the resource included in the exclusive resource pool corresponding to the first thread is greater than a first threshold after the operation of the first thread is finished, where:
And the resources in the shared resources are used for providing resources for a plurality of threads, and the threads comprise the first thread.
Since the apparatus 200 is an apparatus corresponding to the method provided in the above method embodiment, the specific implementation of each unit of the apparatus 200 is the same as the above method embodiment, and therefore, with respect to the specific implementation of each unit of the apparatus 200, reference may be made to the description part of the above method embodiment, and details are not repeated herein.
The method provided by the embodiment of the application can be executed by the client or the server, and the client and the server for executing the method are respectively described below.
Fig. 3 shows a block diagram of a client 300. For example, the client 300 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, an exercise device, a personal digital assistant, and the like.
Referring to FIG. 3, a client 300 may include one or more of a processing component 302, a memory 304, a power supply component 306, a multimedia component 308, an audio component 310, an input/output (I/O) interface 33, a sensor component 314, and a communication component 316.
The processing component 302 generally controls overall operation of the client 300, such as operations associated with display, telephone calls, data communications, camera operations, and recording operations. The processing element 302 may include one or more processors 320 to execute instructions to perform all or part of the steps of the methods described above. Further, the processing component 302 can include one or more modules that facilitate interactions between the processing component 302 and other components. For example, the processing component 302 may include a multimedia module to facilitate interaction between the multimedia component 308 and the processing component 302.
Memory 304 is configured to store various types of data to support operations at client 300. Examples of such data include instructions for any application or method operating on client 300, contact data, phonebook data, messages, pictures, video, and the like. The memory 304 may be implemented by any type or combination of volatile or nonvolatile memory devices such as Static Random Access Memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic or optical disk.
The power supply component 306 provides power to the various components of the client 300. The power components 306 may include a power management system, one or more power sources, and other components associated with generating, managing, and distributing power for the client 300.
The multimedia component 308 includes a screen between the client 300 and the user that provides an output interface. In some embodiments, the screen may include a Liquid Crystal Display (LCD) and a Touch Panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from a user. The touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. The touch sensor may sense not only the boundary of a touch or slide action, but also the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 308 includes a front-facing camera and/or a rear-facing camera. When the client 300 is in an operation mode, such as a photographing mode or a video mode, the front camera and/or the rear camera may receive external multimedia data. Each front camera and rear camera may be a fixed optical lens system or have focal length and optical zoom capabilities.
The audio component 310 is configured to output and/or input audio signals. For example, the audio component 310 includes a Microphone (MIC) configured to receive external audio signals when the client 300 is in an operational mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signals may be further stored in the memory 304 or transmitted via the communication component 316. In some embodiments, audio component 310 further comprises a speaker for outputting audio signals.
The I/O interface provides an interface between the processing component 302 and peripheral interface modules, which may be keyboards, click wheels, buttons, etc. These buttons may include, but are not limited to, a home button, a volume button, an activate button, and a lock button.
The sensor assembly 314 includes one or more sensors for providing status assessment of various aspects for the client 300. For example, the sensor assembly 314 may detect an on/off state of the device 300, a relative positioning of the components, such as a display and keypad of the client 300, the sensor assembly 314 may also detect a change in position of the client 300 or a component of the client 300, the presence or absence of user contact with the client 300, the orientation or acceleration/deceleration of the client 300, and a change in temperature of the client 300. The sensor assembly 314 may include a proximity sensor configured to detect the presence of nearby objects in the absence of any physical contact. The sensor assembly 314 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 314 may also include an acceleration sensor, a gyroscopic sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
The communication component 316 is configured to facilitate communication between the client 300 and other devices, either wired or wireless. The client 300 may access a wireless network based on a communication standard, such as WiFi,2G, or 3G, or a combination thereof. In one exemplary embodiment, the communication part 316 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 316 further includes a Near Field Communication (NFC) module to facilitate short range communications. For example, the NFC module may be implemented based on Radio Frequency Identification (RFID) technology, infrared data association (IrDA) technology, ultra Wideband (UWB) technology, bluetooth (BT) technology, and other technologies.
In an exemplary embodiment, the client 300 may be implemented by one or more Application Specific Integrated Circuits (ASICs), digital Signal Processors (DSPs), digital Signal Processing Devices (DSPDs), programmable Logic Devices (PLDs), field Programmable Gate Arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic elements for performing the following methods:
Acquiring resources from an exclusive resource pool corresponding to a first thread, wherein the exclusive resource pool corresponding to the first thread is used for providing resources for the first thread;
and running the first thread by using the acquired resources.
In one implementation, before the obtaining the resource from the exclusive resource pool corresponding to the first thread, the method further includes:
and determining that resources exist in an exclusive resource pool corresponding to the first thread.
In one implementation, the method further comprises:
Under the condition that no resource exists in the exclusive resource pool corresponding to the first thread, locking a shared resource pool and acquiring the resource from the shared resource pool, wherein:
and the resources in the shared resource pool are used for providing resources for a plurality of threads, wherein the threads comprise the first thread.
In one implementation, before determining that no resource exists in the exclusive resource pool corresponding to the first thread, the locking the shared resource pool and acquiring a resource from the shared resource pool further includes:
determining that resources exist in the shared resource pool.
In one implementation, the method further comprises:
creating a resource for the first thread if it is determined that no resource exists in the shared resource pool;
running the first thread by using the acquired resources, including:
And running the first thread by using the created resources.
In one implementation, the method further comprises:
And after the first thread is operated, if the resources included in the exclusive resource pool corresponding to the first thread are smaller than or equal to a first threshold, releasing the acquired resources into the exclusive resource pool corresponding to the first thread.
In one implementation, the method further comprises:
after the first thread is operated, if the resources included in the exclusive resource pool corresponding to the first thread are greater than a first threshold, locking a shared resource pool and releasing the acquired resources into the shared resource pool, wherein:
And the resources in the shared resources are used for providing resources for a plurality of threads, and the threads comprise the first thread.
Fig. 4 is a schematic structural diagram of a server according to an embodiment of the present application. The server 400 may vary considerably in configuration or performance and may include one or more central processing units (central processing units, CPUs) 422 (e.g., one or more processors) and memory 432, one or more storage mediums 430 (e.g., one or more mass storage devices) that store applications 442 or data 444. Wherein memory 432 and storage medium 430 may be transitory or persistent storage. The program stored on the storage medium 430 may include one or more modules (not shown), each of which may include a series of instruction operations on a server. Still further, the central processor 422 may be configured to communicate with the storage medium 430 and execute a series of instruction operations in the storage medium 430 on the server 400.
Still further, the central processor 422 may perform the following method:
Acquiring resources from an exclusive resource pool corresponding to a first thread, wherein the exclusive resource pool corresponding to the first thread is used for providing resources for the first thread;
and running the first thread by using the acquired resources.
In one implementation, before the obtaining the resource from the exclusive resource pool corresponding to the first thread, the method further includes:
and determining that resources exist in an exclusive resource pool corresponding to the first thread.
In one implementation, the method further comprises:
Under the condition that no resource exists in the exclusive resource pool corresponding to the first thread, locking a shared resource pool and acquiring the resource from the shared resource pool, wherein:
and the resources in the shared resource pool are used for providing resources for a plurality of threads, wherein the threads comprise the first thread.
In one implementation, before determining that no resource exists in the exclusive resource pool corresponding to the first thread, the locking the shared resource pool and acquiring a resource from the shared resource pool further includes:
determining that resources exist in the shared resource pool.
In one implementation, the method further comprises:
creating a resource for the first thread if it is determined that no resource exists in the shared resource pool;
running the first thread by using the acquired resources, including:
And running the first thread by using the created resources.
In one implementation, the method further comprises:
And after the first thread is operated, if the resources included in the exclusive resource pool corresponding to the first thread are smaller than or equal to a first threshold, releasing the acquired resources into the exclusive resource pool corresponding to the first thread.
In one implementation, the method further comprises:
after the first thread is operated, if the resources included in the exclusive resource pool corresponding to the first thread are greater than a first threshold, locking a shared resource pool and releasing the acquired resources into the shared resource pool, wherein:
And the resources in the shared resources are used for providing resources for a plurality of threads, and the threads comprise the first thread.
The server 400 may also include one or more power supplies 426, one or more wired or wireless network interfaces 450, one or more input/output interfaces 456, one or more keyboards 456, and/or one or more operating systems 441, such as Windows ServerTM, mac OS XTM, unixTM, linuxTM, freeBSDTM, and the like.
Embodiments of the present application also provide a computer readable medium having instructions stored thereon, which when executed by one or more processors, cause an apparatus to perform the resource processing method provided by the above method embodiments.
Other embodiments of the application will be apparent to those skilled in the art from consideration of the specification and practice of the application disclosed herein. This application is intended to cover any variations, uses, or adaptations of the application following, in general, the principles of the application and including such departures from the present disclosure as come within known or customary practice within the art to which the application pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the application being indicated by the following claims.
It is to be understood that the application is not limited to the precise arrangements and instrumentalities shown in the drawings, which have been described above, and that various modifications and changes may be effected without departing from the scope thereof. The scope of the application is limited only by the appended claims
The foregoing description of the preferred embodiments of the application is not intended to limit the application to the precise form disclosed, and any such modifications, equivalents, and alternatives falling within the spirit and scope of the application are intended to be included within the scope of the application.

Claims (7)

1. A method of resource processing, the method comprising:
in an initialization stage of a service, respectively creating an exclusive resource pool for each thread, wherein the service comprises one or more services, and the services run in the threads;
Determining that resources exist in an exclusive resource pool corresponding to a first thread, and acquiring the resources from the exclusive resource pool corresponding to the first thread, wherein the exclusive resource pool corresponding to the first thread is only used for providing the resources for the first thread, and the resources comprise one or more of a thread pool, a memory pool and a connection pool;
operating the first thread by using the acquired resources;
under the condition that no resource exists in an exclusive resource pool corresponding to the first thread, locking a shared resource pool, acquiring the resource from the shared resource pool, and running the first thread by utilizing the resource;
When it is determined that no resource exists in an exclusive resource pool corresponding to the first thread and no resource exists in a shared resource pool, creating a resource for the first thread, and running the first thread by using the created resource, wherein the resource in the shared resource pool is used for providing resources for a plurality of threads;
after the first thread is operated, if the resources included in the exclusive resource pool corresponding to the first thread are smaller than or equal to a first threshold, releasing the acquired resources into the exclusive resource pool corresponding to the first thread;
And if the resources included in the exclusive resource pool corresponding to the first thread are larger than a first threshold, locking a shared resource pool, and releasing the acquired resources into the shared resource pool.
2. The method of claim 1, wherein, in the case where it is determined that no resource exists in the exclusive resource pool corresponding to the first thread, the locking the shared resource pool and before obtaining a resource from the shared resource pool, further comprises:
determining that resources exist in the shared resource pool.
3. A resource processing apparatus, the apparatus comprising:
The device comprises an acquisition unit, a first thread and a second thread, wherein the acquisition unit is used for determining that resources exist in an exclusive resource pool corresponding to the first thread, acquiring the resources from the exclusive resource pool corresponding to the first thread, wherein the exclusive resource pool corresponding to the first thread is only used for providing the resources for the first thread, and the resources comprise one or more of a thread pool, a memory pool and a connection pool;
The running unit is used for running the first thread by utilizing the acquired resources;
The first release unit is used for releasing the acquired resources into the exclusive resource pool corresponding to the first thread if the resources included in the exclusive resource pool corresponding to the first thread are smaller than or equal to a first threshold after the first thread is operated, wherein the first threshold is determined according to the resources required for operating the first thread;
The second releasing unit is configured to lock a shared resource pool and release the acquired resource to the shared resource pool if the resource included in the exclusive resource pool corresponding to the first thread is greater than a first threshold after the operation of the first thread is finished;
The system comprises a first thread, a creating unit, a service and a service processing unit, wherein the first thread is used for providing resources for a plurality of threads when the fact that resources do not exist in an exclusive resource pool corresponding to the first thread and resources do not exist in a shared resource pool is determined;
The operation unit is used for:
Running the first thread by using the created resource;
And the locking unit is used for locking the shared resource pool, acquiring the resources from the shared resource pool and running the first thread by utilizing the resources under the condition that the resources do not exist in the exclusive resource pool corresponding to the first thread.
4. A device according to claim 3, characterized in that the device further comprises:
And the second determining unit is used for determining that the resources exist in the shared resource pool before the shared resource pool is locked and the resources are acquired from the shared resource pool.
5. A resource processing device comprising a memory, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by one or more processors, the one or more programs comprising instructions for:
in an initialization stage of a service, respectively creating an exclusive resource pool for each thread, wherein the service comprises one or more services, and the services run in the threads;
Determining that resources exist in an exclusive resource pool corresponding to a first thread, and acquiring the resources from the exclusive resource pool corresponding to the first thread, wherein the exclusive resource pool corresponding to the first thread is only used for providing the resources for the first thread, and the resources comprise one or more of a thread pool, a memory pool and a connection pool;
operating the first thread by using the acquired resources;
Under the condition that no resource exists in the exclusive resource pool corresponding to the first thread, locking a shared resource pool, and acquiring the resource from the shared resource pool;
When it is determined that no resource exists in an exclusive resource pool corresponding to the first thread and no resource exists in a shared resource pool, creating a resource for the first thread, and running the first thread by using the created resource, wherein the resource in the shared resource pool is used for providing resources for a plurality of threads;
After the first thread is finished running, if the resources included in the exclusive resource pool corresponding to the first thread are smaller than or equal to a first threshold value, releasing the acquired resources into the exclusive resource pool corresponding to the first thread;
if the resources included in the exclusive resource pool corresponding to the first thread are larger than a first threshold, locking a shared resource pool, and releasing the acquired resources into the shared resource pool;
wherein the first threshold is determined based on resources required to run the first thread.
6. The apparatus of claim 5, wherein the locking the shared resource pool and the obtaining resources from the shared resource pool, if it is determined that no resources exist in the exclusive resource pool corresponding to the first thread, further comprises:
determining that resources exist in the shared resource pool.
7. A computer readable medium having instructions stored thereon, which when executed by one or more processors, cause an apparatus to perform the method of any of claims 1 to 2.
CN202011194968.4A 2020-10-30 2020-10-30 Resource processing method and device Active CN112286687B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011194968.4A CN112286687B (en) 2020-10-30 2020-10-30 Resource processing method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011194968.4A CN112286687B (en) 2020-10-30 2020-10-30 Resource processing method and device

Publications (2)

Publication Number Publication Date
CN112286687A CN112286687A (en) 2021-01-29
CN112286687B true CN112286687B (en) 2025-07-11

Family

ID=74353790

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011194968.4A Active CN112286687B (en) 2020-10-30 2020-10-30 Resource processing method and device

Country Status (1)

Country Link
CN (1) CN112286687B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116527815A (en) * 2023-04-18 2023-08-01 贝壳找房(北京)科技有限公司 Outgoing call method, device and electronic equipment
CN117082339B (en) * 2023-07-13 2024-10-11 荣耀终端有限公司 Shooting mode switching method and device, electronic equipment and readable storage medium

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107515785A (en) * 2016-06-16 2017-12-26 大唐移动通信设备有限公司 A kind of EMS memory management process and device

Family Cites Families (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6651158B2 (en) * 2001-06-22 2003-11-18 Intel Corporation Determination of approaching instruction starvation of threads based on a plurality of conditions
CN100512206C (en) * 2004-11-18 2009-07-08 华为技术有限公司 Buffer resource management method for grouping converter
US20070094669A1 (en) * 2005-10-25 2007-04-26 Microsoft Corporation Shared resource acquisition
CN101566977B (en) * 2009-06-08 2011-02-02 华为技术有限公司 Method, device and system of processor accessing shared data
CA2891984C (en) * 2015-04-20 2016-09-13 Anant Asthana Systems and methods for allocating online resources
CN105426250A (en) * 2015-11-30 2016-03-23 杭州数梦工场科技有限公司 Resource management method and apparatus
CN111274015A (en) * 2016-08-31 2020-06-12 华为技术有限公司 Configuration method and device and data processing server
CN110457135A (en) * 2019-08-09 2019-11-15 重庆紫光华山智安科技有限公司 A kind of method of resource regulating method, device and shared GPU video memory

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107515785A (en) * 2016-06-16 2017-12-26 大唐移动通信设备有限公司 A kind of EMS memory management process and device

Also Published As

Publication number Publication date
CN112286687A (en) 2021-01-29

Similar Documents

Publication Publication Date Title
JP6189000B2 (en) Application installation package processing method, apparatus, program, and recording medium
EP3136793A1 (en) Method and apparatus for awakening electronic device
US10558328B2 (en) Display screen unlocking method and apparatus
CN107094094B (en) Application networking method and device and terminal
CN112286687B (en) Resource processing method and device
EP3236355B1 (en) Method and apparatus for managing task of instant messaging application
WO2016150104A1 (en) App theme loading method and device
CN108958911B (en) Process control method and device
CN109117144B (en) Page processing method, device, terminal and storage medium
CN113360254B (en) Task scheduling method and system
US11269699B2 (en) Method and device for processing an application
CN107885464B (en) Data storage method, device, and computer-readable storage medium
CN107371222B (en) Virtual card disabling method and device
CN105786561B (en) Method and device for calling process
CN110515623B (en) Method and device for realizing graphic operation, electronic equipment and storage medium
CN105893128B (en) A method and device for application call management
CN109586951B (en) Method, device, electronic equipment and readable storage medium for implementing fault transfer
CN109491655B (en) Input event processing method and device
CN117176778A (en) Connection pool management method, device and storage medium
CN112083981A (en) Method and device for creating page view component
CN115052100B (en) Image processing method and device
CN112651012B (en) Information processing method and device
CN112765512B (en) Delayed loading detection method, device, electronic device, storage medium and product
CN115391018B (en) Task scheduling method, device and equipment
CN113297549B (en) Authority control method, device, equipment and computer readable storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
TG01 Patent term adjustment
TG01 Patent term adjustment