CN112286687A - Resource processing method and device - Google Patents
Resource processing method and device Download PDFInfo
- Publication number
- CN112286687A CN112286687A CN202011194968.4A CN202011194968A CN112286687A CN 112286687 A CN112286687 A CN 112286687A CN 202011194968 A CN202011194968 A CN 202011194968A CN 112286687 A CN112286687 A CN 112286687A
- Authority
- CN
- China
- Prior art keywords
- thread
- resource
- resource pool
- exclusive
- resources
- 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.)
- Pending
Links
- 238000003672 processing method Methods 0.000 title description 12
- 238000000034 method Methods 0.000 claims abstract description 50
- 238000012545 processing Methods 0.000 claims description 26
- 238000005516 engineering process Methods 0.000 abstract description 11
- 238000004891 communication Methods 0.000 description 10
- 238000010586 diagram Methods 0.000 description 6
- 238000011176 pooling Methods 0.000 description 5
- 230000005236 sound signal Effects 0.000 description 4
- 230000003287 optical effect Effects 0.000 description 3
- 230000001133 acceleration Effects 0.000 description 2
- 230000008859 change Effects 0.000 description 2
- 230000003993 interaction Effects 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 230000008569 process Effects 0.000 description 2
- 230000009471 action Effects 0.000 description 1
- 230000006978 adaptation Effects 0.000 description 1
- 238000003491 array Methods 0.000 description 1
- 230000006870 function Effects 0.000 description 1
- 238000003384 imaging method Methods 0.000 description 1
- 230000006872 improvement Effects 0.000 description 1
- 239000004973 liquid crystal related substance Substances 0.000 description 1
- 230000002093 peripheral effect Effects 0.000 description 1
- 230000002085 persistent effect Effects 0.000 description 1
- 238000011160 research Methods 0.000 description 1
- 230000003068 static effect Effects 0.000 description 1
- 230000001052 transient effect Effects 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements 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/46—Multiprogramming arrangements
- G06F9/50—Allocation of resources, e.g. of the central processing unit [CPU]
- G06F9/5005—Allocation of resources, e.g. of the central processing unit [CPU] to service a request
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F2209/00—Indexing scheme relating to G06F9/00
- G06F2209/50—Indexing scheme relating to G06F9/50
- G06F2209/503—Resource 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)
- Debugging And Monitoring (AREA)
Abstract
In the method, each thread may have a corresponding exclusive resource pool, and taking the first thread as an example, the first thread may have an exclusive resource pool corresponding to the first thread, and the exclusive resource pool corresponding to the first thread is only used for providing resources for the first thread, but not for providing resources for other threads. Because of this, other threads except the first thread 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 as the shared resource pool in the conventional technology. When the first thread needs to be run, the resource can be directly acquired from the exclusive resource pool corresponding to the first thread, so that the first thread is run by using the acquired resource. Therefore, the concurrency can be improved by the scheme of the embodiment of the application.
Description
Technical Field
The present application relates to the field of data processing, and in particular, to a resource processing method and apparatus.
Background
Pooling techniques may be utilized to improve the performance of the computer. The pooling technology is that resources are created in advance and are placed in a resource pool, and when the resources need to be used, the resources are directly obtained from the resource pool, so that the consumption of creating the resources is avoided, and the efficiency is improved.
Currently, pooling techniques can be applied to multi-threaded programming. I.e., multiple threads may each acquire resources from the resource pool. However, at most one thread can use the resource in the resource pool at the same time, so that a plurality of threads cannot run simultaneously, and the concurrency is reduced.
Disclosure of Invention
The technical problem to be solved by the application is how to improve concurrency when the pooling technology is applied to multithread programming, and a resource processing method and device are provided.
In a first aspect, an embodiment of the present application provides a resource processing method, where the method includes:
acquiring a resource from an exclusive resource pool corresponding to a first thread, wherein the exclusive resource pool corresponding to the first thread is used for providing the resource for the first thread;
and running the first thread by using the acquired resources.
Optionally, before obtaining the resource from the exclusive resource pool corresponding to the first thread, the method further includes:
and determining that the resource exists in the exclusive resource pool corresponding to the first thread.
Optionally, the method further includes:
under the condition that the resource does not exist 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, and the plurality of threads comprise the first thread.
Optionally, when it is determined that a resource does not exist in the exclusive resource pool corresponding to the first thread, before the locking the shared resource pool and acquiring the resource from the shared resource pool, the method further includes:
determining that a resource exists in the shared resource pool.
Optionally, the method further includes:
creating a resource for the first thread if it is determined that no resource exists in the shared resource pool;
executing the first thread by using the acquired resource, wherein the executing comprises:
and running the first thread by utilizing the created resources.
Optionally, the method further includes:
after the first thread is finished running, if the resource included in the exclusive resource pool corresponding to the first thread is smaller than or equal to a first threshold value, releasing the acquired resource to the exclusive resource pool corresponding to the first thread.
Optionally, the method further includes:
after the first thread finishes running, if the resource included in the exclusive resource pool corresponding to the first thread is larger than a first threshold value, locking a shared resource pool, and releasing the acquired resource to the shared resource pool; wherein:
and the resource in the shared resource is used for providing resources for a plurality of threads, and the plurality of threads comprise the first thread.
In a second aspect, an embodiment of the present application provides a resource processing apparatus, where the apparatus includes:
the system comprises an acquisition unit, a processing unit and a processing unit, wherein the acquisition unit is used for acquiring resources from an exclusive resource pool corresponding to a first thread, and the exclusive resource pool corresponding to the first thread is used for providing the resources for the first thread;
and the running unit is used for running the first thread by utilizing the acquired resources.
Optionally, the apparatus further comprises:
a first determining unit, configured to determine that a resource exists in an exclusive resource pool corresponding to a first thread before the resource is acquired from the exclusive resource pool corresponding to the first thread.
Optionally, the apparatus further comprises:
a locking unit, configured to lock a shared resource pool and obtain a resource from the shared resource pool when it is determined that no resource exists in an 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, and the plurality of threads comprise the first thread.
Optionally, the apparatus further comprises:
a second determining unit, configured to determine that a resource exists in the shared resource pool before locking the shared resource pool and acquiring the resource from the shared resource pool.
Optionally, the apparatus further comprises:
a creating unit, configured to create a resource for the first thread when it is determined that no resource exists in the shared resource pool;
the operation unit is used for:
and running the first thread by utilizing the created resources.
Optionally, the apparatus further comprises:
a first releasing unit, configured to release, after the first thread is finished running, the acquired resource to an exclusive resource pool corresponding to the first thread if a resource included in the exclusive resource pool corresponding to the first thread is smaller than or equal to a first threshold.
Optionally, the apparatus further comprises:
a second releasing unit, configured to lock a shared resource pool and release the acquired resource to the shared resource pool if a resource included in an exclusive resource pool corresponding to the first thread is greater than a first threshold after the first thread finishes running; wherein:
and the resource in the shared resource is used for providing resources for a plurality of threads, and the plurality of threads comprise the first thread.
In a third aspect, an embodiment of the present application provides a resource processing apparatus, including a memory, and one or more programs, where the one or more programs are stored in the memory, and configured to be executed by the one or more processors includes instructions for:
acquiring a resource from an exclusive resource pool corresponding to a first thread, wherein the exclusive resource pool corresponding to the first thread is used for providing the resource for the first thread;
and running the first thread by using the acquired resources.
Optionally, before obtaining the resource from the exclusive resource pool corresponding to the first thread, the method further includes:
and determining that the resource exists in the exclusive resource pool corresponding to the first thread.
Optionally, the operations further include:
under the condition that the resource does not exist 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, and the plurality of threads comprise the first thread.
Optionally, when it is determined that a resource does not exist in the exclusive resource pool corresponding to the first thread, before the locking the shared resource pool and acquiring the resource from the shared resource pool, the method further includes:
determining that a resource exists 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;
executing the first thread by using the acquired resource, wherein the executing comprises:
and running the first thread by utilizing the created resources.
Optionally, the operations further include:
after the first thread is finished running, if the resource included in the exclusive resource pool corresponding to the first thread is smaller than or equal to a first threshold value, releasing the acquired resource to the exclusive resource pool corresponding to the first thread.
Optionally, the operations further include:
after the first thread finishes running, if the resource included in the exclusive resource pool corresponding to the first thread is larger than a first threshold value, locking a shared resource pool, and releasing the acquired resource to the shared resource pool; wherein:
and the resource in the shared resource is used for providing resources for a plurality of threads, and the plurality of threads comprise the first thread.
In a fourth aspect, embodiments of the present application provide a computer-readable medium having stored thereon instructions, which, when executed by one or more processors, cause an apparatus to perform the method of any of the above first aspects.
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 plurality of threads do not share a shared resource pool as in the conventional technology, and if a first thread needs to be run, the resource can be obtained 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 run. In this application, each thread may have a corresponding exclusive resource pool, and taking the first thread as an example, the first thread may have an exclusive resource pool corresponding to the first thread, and the exclusive resource pool corresponding to the first thread is only used for providing resources for the first thread, but not for providing resources for other threads. Because of this, other threads except the first thread 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 as the shared resource pool in the conventional technology. When the first thread needs to be run, the resource can be directly acquired from the exclusive resource pool corresponding to the first thread, so that the first thread is run by using the acquired resource. Therefore, the concurrency can be improved by the scheme of the embodiment of the application.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings needed to be used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments described in the present application, and other drawings can be obtained by those skilled in the art without creative efforts.
Fig. 1 is a schematic flowchart of a resource processing method according to an embodiment of the present application;
fig. 2 is a schematic structural diagram of a resource processing apparatus according to an embodiment of the present disclosure;
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 technical solutions of the present application better understood, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
The inventor of the application finds that the pooling technology can be applied to multi-thread programming through research. 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. At present, when a plurality of threads all acquire resources from a shared resource pool, at most one thread can use the resources in the resource pool at the same time. Specifically, when the thread 1 needs to acquire the resource from the shared resource pool, the thread 1 may first lock the shared resource pool (which may also be referred to as locking the shared resource pool), then acquire the resource from the shared resource pool to run the thread 1, after the thread 1 finishes running, release the resource to the shared resource pool, and then release the lock on 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 unlocks the shared resource pool before it can 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 problem, embodiments of the present application provide a resource processing method and apparatus.
Various non-limiting embodiments of the present application are described in detail below with reference to the accompanying drawings.
Exemplary method
Referring to fig. 1, the figure is a schematic flowchart of a resource processing method according to an embodiment of the present application.
The resource processing method provided in the embodiment of the present 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, which is not particularly limited in the embodiment of the present application. The device including the controller or the processor includes, but is not limited to, a terminal device and a server.
In the present embodiment, the resource processing method shown in fig. 1 may include the following steps S101 to S102, for example.
S101: and acquiring resources from an exclusive resource pool corresponding to the first thread, wherein the exclusive resource pool corresponding to the first thread is used for providing the resources for the first thread.
In the embodiment of the application, an exclusive resource pool can be created for each thread in the initialization phase of the service. Where a service may include one or more services, the services 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 is not used for providing resources for other threads. In this embodiment of the application, the resource in the exclusive resource pool corresponding to the first thread may include, for example, one or more of a thread pool, a memory pool, and a connection pool. Thread pools, memory pools, and connection pools are not described in detail herein.
In this embodiment of the present application, when a service needs to be run by using a first thread, a resource may be obtained from an exclusive resource pool corresponding to the first thread.
S102: and running the first thread by using the acquired resources.
After the resource is acquired from the exclusive resource pool corresponding to the first thread, the first thread may be run by using the resource acquired from the exclusive resource pool corresponding to the first thread, so as to implement processing of a certain service.
As can be seen from the above description, the exclusive resource pool corresponding to the first thread is only used for providing resources for the first thread, and is not used for providing resources for other threads. Therefore, except for the first thread, other threads 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 run, the resource can be directly acquired from the exclusive resource pool corresponding to the first thread, so that the first thread is run by using the acquired resource. Therefore, the concurrency can be improved by the scheme of the embodiment of the application.
In some scenarios, when the service processing is completed, the resources used to process the service may be released. In the service processing process, there may be multi-thread mutual scheduling, which may cause that the resource acquired from the exclusive resource pool of the first thread may be released to other threads, for example, the exclusive resource pool of the second thread, so that the resource in the exclusive resource pool corresponding to the first thread is less and less, and even no resource is available. And more resources are reserved in the exclusive resource pool corresponding to the second thread.
For example, for user login service, there are thread 1 applying for a link to verify if the username and password match and thread 2 returning the link. When the thread 1 is operated, the resource is obtained from the exclusive resource pool corresponding to the thread 1, and the thread operated by returning the link is the thread 2, so that after the user name and the password are verified to be matched, and the link is further returned, the resource obtained from the exclusive resource pool of the thread 1 is released into the exclusive resource pool corresponding to the thread 2, so that the resource in the exclusive resource pool corresponding to the thread 1 is reduced, and the resource in the exclusive resource pool corresponding to the thread 2 is increased.
Since there is no resource available in the exclusive resource pool corresponding to the first thread as described above, in an example of the embodiment of the present application, before executing the foregoing S101, it may be further determined whether a resource exists in the exclusive resource pool corresponding to the first thread, and if it is determined that a resource exists 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 by using the resource in the exclusive resource pool of the first thread.
In addition, in order to enable the first thread to normally run under the condition that no resource exists in the exclusive resource pool corresponding to the first thread. In the embodiment of the present application, in an initialization phase of a service, in addition to creating an exclusive resource pool for each thread, a shared resource pool may be created, where the shared resource pool is used to provide resources for a plurality of threads, where 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 can be acquired from the shared resource pool, and the first thread can be run by using the resource acquired from the shared resource pool. Specifically, before acquiring a resource from the shared resource pool, the shared resource pool may be first locked, and then the resource may be acquired from the shared resource pool.
In some scenarios of embodiments of the present application, during an initialization phase of a service, resources exist in a shared resource pool. But as the service runs, there may or may not still be resources in the shared resource pool. For specific reasons, reference may be made to the following description of the resource release section, which is not analyzed in detail here. Therefore, in an implementation manner of the embodiment of the present application, before locking the shared resource pool, it may be further 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 the resource is acquired from the shared resource pool to run the first thread.
In an example of the embodiment of the present application, if there is no resource in an exclusive resource pool corresponding to a first thread and a shared resource pool does not include the resource, a new resource may be created for the first thread, and the first thread may be run by using the created resource, so that the first thread may run normally.
In this embodiment, after the first thread finishes running, the resource used for running the first thread may be released, that is, the acquired resource mentioned in S102 is released. In some embodiments, considering that if there is a resource in the exclusive resource pool corresponding to the first thread, the concurrency may be improved to the greatest extent, and it is avoided that when the first thread needs to be run, the resource needs to be acquired from the shared resource pool or re-created, so after the first thread is run, the resource used for running the first thread may be released into the exclusive resource pool corresponding to the first thread.
It should be understood that the resource used for running the first thread mentioned herein may be obtained from an exclusive resource pool corresponding to the first thread, may also be obtained from a shared resource pool, and may also be temporarily created for the first thread. The embodiments of the present application are not particularly limited. Even if the resource used for running the first thread is obtained from the shared resource pool, the resource can be released to the exclusive resource pool corresponding to the first thread, and therefore, along with the running of the service, the resource may not exist in the shared resource pool.
In other embodiments, it is contemplated that the resources required to run the first thread are generally limited, e.g., do not exceed the first threshold. Therefore, when the resource originally included in the exclusive resource pool of the first thread exceeds the first threshold, it is indicated that there is enough resource in the exclusive resource pool corresponding to the first thread to run the first thread, and for this situation, in this embodiment of the present application, the resource used for running the first thread may be released into the shared resource pool, so that the shared resource pool may provide resource for other threads, and the problem of low overall resource utilization rate caused by too much resource in the resource pool corresponding to the first thread may also be avoided. Specifically, the shared resource pool may be locked, the resource used to run the first thread may be released into the shared resource pool, and after the resource used to run the first thread is released into the shared resource pool, the lock on the shared resource pool may be released.
In other words, in the embodiment of the present application, after the first thread is finished running, if the resource included in the exclusive resource pool corresponding to the first thread is less than or equal to the first threshold, the resource used for running the first thread is released into the exclusive resource pool corresponding to the first thread, so as to improve the concurrency to the maximum extent. After the first thread finishes running, if the resource included in the exclusive resource pool corresponding to the first thread is greater than a first threshold value, locking a shared resource pool, and releasing the acquired resource to the shared resource pool, so that the shared resource pool can provide resources for other threads.
Exemplary device
Based on the method provided by the above embodiment, the embodiment of the present application further provides a resource processing apparatus, which is described below with reference to the accompanying drawings.
Referring to fig. 2, this figure is a schematic structural diagram of a resource processing apparatus according to an embodiment of the present application. The apparatus 200 may specifically include, for example: an acquisition unit 201 and an execution 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;
the running unit 202 is configured to run the first thread by using the acquired resource.
In one implementation, the apparatus further comprises:
a first determining unit, configured to determine that a resource exists in an exclusive resource pool corresponding to a first thread before the resource is acquired from the exclusive resource pool corresponding to the first thread.
In one implementation, the apparatus further comprises:
a locking unit, configured to lock a shared resource pool and obtain a resource from the shared resource pool when it is determined that no resource exists in an 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, and the plurality of threads comprise the first thread.
In one implementation, the apparatus further comprises:
a second determining unit, configured to determine that a resource exists in the shared resource pool before locking the shared resource pool and acquiring the resource from the shared resource pool.
In one implementation, the apparatus further comprises:
a creating unit, configured to create a resource for the first thread when 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 utilizing the created resources.
In one implementation, the apparatus further comprises:
a first releasing unit, configured to release, after the first thread is finished running, the acquired resource to an exclusive resource pool corresponding to the first thread if a resource included in the exclusive resource pool corresponding to the first thread is smaller than or equal to a first threshold.
In one implementation, the apparatus further comprises:
a second releasing unit, configured to lock a shared resource pool and release the acquired resource to the shared resource pool if a resource included in an exclusive resource pool corresponding to the first thread is greater than a first threshold after the first thread finishes running; wherein:
and the resource in the shared resource is used for providing resources for a plurality of threads, and the plurality of threads comprise the first thread.
Since the apparatus 200 is an apparatus corresponding to the method provided in the above method embodiment, and the specific implementation of each unit of the apparatus 200 is the same as that of the above method embodiment, for 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 here.
The method provided by the embodiment of the present application may be executed by a client or a server, and the client and the server that execute the method are described below separately.
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, a fitness device, a personal digital assistant, and the like.
Referring to fig. 3, client 300 may include one or more of the following components: processing component 302, memory 304, power component 306, multimedia component 308, audio component 310, input/output (I/O) interface 33, sensor component 314, and 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 elements 302 may include one or more processors 320 to execute instructions to perform all or a portion of the steps of the methods described above. Further, the processing component 302 can include one or more modules that facilitate interaction between the processing component 302 and other components. For example, the processing component 302 can include a multimedia module to facilitate interaction between the multimedia component 308 and the processing component 302.
The memory 304 is configured to store various types of data to support operations at the client 300. Examples of such data include instructions for any application or method operating on the client 300, contact data, phonebook data, messages, pictures, videos, and so forth. The memory 304 may be implemented by any type or combination of volatile or non-volatile 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 disks.
The power 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 supplies, and other components associated with generating, managing, and distributing power for the client 300.
The multimedia component 308 comprises a screen providing an output interface between the client 300 and the user. 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 an input signal from a user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundary of a touch or slide action, but also detect 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. The front camera and/or the rear camera may receive external multimedia data when the client 300 is in an operation mode, such as a photographing mode or a video mode. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
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 operating mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signals may further be stored in the memory 304 or transmitted via the communication component 316. In some embodiments, audio component 310 also includes 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, a start button, and a lock button.
The communication component 316 is configured to facilitate communications between the client 300 and other devices in a wired or wireless manner. The client 300 may access a wireless network based on a communication standard, such as WiFi, 2G or 3G, or a combination thereof. In an exemplary embodiment, the communication section 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, micro-controllers, microprocessors or other electronic components for performing the following methods:
acquiring a resource from an exclusive resource pool corresponding to a first thread, wherein the exclusive resource pool corresponding to the first thread is used for providing the resource 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 the resource exists in the exclusive resource pool corresponding to the first thread.
In one implementation, the method further comprises:
under the condition that the resource does not exist 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, and the plurality of threads comprise the first thread.
In an implementation manner, when it is determined that a resource does not exist in the exclusive resource pool corresponding to the first thread, before the locking the shared resource pool and acquiring the resource from the shared resource pool, the method further includes:
determining that a resource exists 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;
executing the first thread by using the acquired resource, wherein the executing comprises:
and running the first thread by utilizing the created resources.
In one implementation, the method further comprises:
after the first thread is finished running, if the resource included in the exclusive resource pool corresponding to the first thread is smaller than or equal to a first threshold value, releasing the acquired resource to the exclusive resource pool corresponding to the first thread.
In one implementation, the method further comprises:
after the first thread finishes running, if the resource included in the exclusive resource pool corresponding to the first thread is larger than a first threshold value, locking a shared resource pool, and releasing the acquired resource to the shared resource pool; wherein:
and the resource in the shared resource is used for providing resources for a plurality of threads, and the plurality of threads comprise the first thread.
Fig. 4 is a schematic structural diagram of a server in an embodiment of the present application. The server 400 may vary significantly due to configuration or performance, and may include one or more Central Processing Units (CPUs) 422 (e.g., one or more processors) and memory 432, one or more storage media 430 (e.g., one or more mass storage devices) storing applications 442 or data 444. Wherein the memory 432 and storage medium 430 may be transient 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 for the server. Still further, the central processor 422 may be arranged 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 a resource from an exclusive resource pool corresponding to a first thread, wherein the exclusive resource pool corresponding to the first thread is used for providing the resource 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 the resource exists in the exclusive resource pool corresponding to the first thread.
In one implementation, the method further comprises:
under the condition that the resource does not exist 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, and the plurality of threads comprise the first thread.
In an implementation manner, when it is determined that a resource does not exist in the exclusive resource pool corresponding to the first thread, before the locking the shared resource pool and acquiring the resource from the shared resource pool, the method further includes:
determining that a resource exists 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;
executing the first thread by using the acquired resource, wherein the executing comprises:
and running the first thread by utilizing the created resources.
In one implementation, the method further comprises:
after the first thread is finished running, if the resource included in the exclusive resource pool corresponding to the first thread is smaller than or equal to a first threshold value, releasing the acquired resource to the exclusive resource pool corresponding to the first thread.
In one implementation, the method further comprises:
after the first thread finishes running, if the resource included in the exclusive resource pool corresponding to the first thread is larger than a first threshold value, locking a shared resource pool, and releasing the acquired resource to the shared resource pool; wherein:
and the resource in the shared resource is used for providing resources for a plurality of threads, and the plurality of 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 Server, Mac OS XTM, UnixTM, LinuxTM, FreeBSDTM, and so forth.
Embodiments of the present application also provide a computer-readable medium having stored thereon instructions, 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 present application will be apparent to those skilled in the art from consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the invention following, in general, the principles of the application and including such departures from the present disclosure as come within known or customary practice in the art to which the invention 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 will be understood that the present application is not limited to the precise arrangements described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the application is limited only by the attached claims
The above description is only exemplary of the present application and should not be taken as limiting the present application, as any modification, equivalent replacement, or improvement made within the spirit and principle of the present application should be included in the protection scope of the present application.
Claims (10)
1. A method for processing resources, the method comprising:
acquiring a resource from an exclusive resource pool corresponding to a first thread, wherein the exclusive resource pool corresponding to the first thread is used for providing the resource for the first thread;
and running the first thread by using the acquired resources.
2. The method according to claim 1, further comprising, before said obtaining the resource from the exclusive resource pool corresponding to the first thread:
and determining that the resource exists in the exclusive resource pool corresponding to the first thread.
3. The method of claim 2, further comprising:
under the condition that the resource does not exist 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, and the plurality of threads comprise the first thread.
4. The method according to claim 3, wherein 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 obtaining the resource from the shared resource pool, further comprising:
determining that a resource exists in the shared resource pool.
5. The method of claim 4, further comprising:
creating a resource for the first thread if it is determined that no resource exists in the shared resource pool;
executing the first thread by using the acquired resource, wherein the executing comprises:
and running the first thread by utilizing the created resources.
6. The method of claim 1, further comprising:
after the first thread is finished running, if the resource included in the exclusive resource pool corresponding to the first thread is smaller than or equal to a first threshold value, releasing the acquired resource to the exclusive resource pool corresponding to the first thread.
7. The method of claim 1, further comprising:
after the first thread finishes running, if the resource included in the exclusive resource pool corresponding to the first thread is larger than a first threshold value, locking a shared resource pool, and releasing the acquired resource to the shared resource pool; wherein:
and the resource in the shared resource is used for providing resources for a plurality of threads, and the plurality of threads comprise the first thread.
8. An apparatus for resource handling, the apparatus comprising:
the system comprises an acquisition unit, a processing unit and a processing unit, wherein the acquisition unit is used for acquiring resources from an exclusive resource pool corresponding to a first thread, and the exclusive resource pool corresponding to the first thread is used for providing the resources for the first thread;
and the running unit is used for running the first thread by utilizing the acquired resources.
9. A resource processing apparatus comprising a memory, and one or more programs, wherein the one or more programs are stored in the memory, and wherein execution of the one or more programs by one or more processors comprises instructions for:
acquiring a resource from an exclusive resource pool corresponding to a first thread, wherein the exclusive resource pool corresponding to the first thread is used for providing the resource for the first thread;
and running the first thread by using the acquired resources.
10. A computer-readable medium having stored thereon instructions, which when executed by one or more processors, cause an apparatus to perform the method of any one of claims 1 to 7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011194968.4A CN112286687A (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 CN112286687A (en) | 2020-10-30 | 2020-10-30 | Resource processing method and device |
Publications (1)
Publication Number | Publication Date |
---|---|
CN112286687A true CN112286687A (en) | 2021-01-29 |
Family
ID=74353790
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202011194968.4A Pending CN112286687A (en) | 2020-10-30 | 2020-10-30 | Resource processing method and device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN112286687A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN117082339A (en) * | 2023-07-13 | 2023-11-17 | 荣耀终端有限公司 | Shooting mode switching method and device, electronic equipment and readable storage medium |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1780252A (en) * | 2004-11-18 | 2006-05-31 | 华为技术有限公司 | Buffer resource management for grouping converter |
CN105426250A (en) * | 2015-11-30 | 2016-03-23 | 杭州数梦工场科技有限公司 | Resource management method and apparatus |
US20160308783A1 (en) * | 2015-04-20 | 2016-10-20 | Peter G. Bookman | Systems and Methods for Allocating Online Resources |
CN107515785A (en) * | 2016-06-16 | 2017-12-26 | 大唐移动通信设备有限公司 | A kind of EMS memory management process and device |
CN110457135A (en) * | 2019-08-09 | 2019-11-15 | 重庆紫光华山智安科技有限公司 | A kind of method of resource regulating method, device and shared GPU video memory |
CN111274015A (en) * | 2016-08-31 | 2020-06-12 | 华为技术有限公司 | Configuration method and device and data processing server |
-
2020
- 2020-10-30 CN CN202011194968.4A patent/CN112286687A/en active Pending
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1780252A (en) * | 2004-11-18 | 2006-05-31 | 华为技术有限公司 | Buffer resource management for grouping converter |
US20160308783A1 (en) * | 2015-04-20 | 2016-10-20 | Peter G. Bookman | Systems and Methods for Allocating Online Resources |
CN105426250A (en) * | 2015-11-30 | 2016-03-23 | 杭州数梦工场科技有限公司 | Resource management method and apparatus |
CN107515785A (en) * | 2016-06-16 | 2017-12-26 | 大唐移动通信设备有限公司 | A kind of EMS memory management process and device |
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 |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN117082339A (en) * | 2023-07-13 | 2023-11-17 | 荣耀终端有限公司 | Shooting mode switching method and device, electronic equipment and readable storage medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN105955765B (en) | Application preloading method and device | |
US9588805B2 (en) | Method and terminal device for controlling background application | |
CN105338409B (en) | Network video preloading method and device | |
CN113032030B (en) | Camera starting method, device, terminal equipment and storage medium | |
CN109254849B (en) | Application program running method and device | |
CN107888965B (en) | Image gift display method and device, terminal, system and storage medium | |
CN112217990B (en) | Task scheduling method, task scheduling device and storage medium | |
KR20170098059A (en) | Electronic device and method for controlling operation thereof | |
US10558328B2 (en) | Display screen unlocking method and apparatus | |
US20170293494A1 (en) | Method and device for starting application interface | |
CN105930213A (en) | Application running method and apparatus | |
KR20160064036A (en) | Method and apparatus for memory optimization | |
EP3236355B1 (en) | Method and apparatus for managing task of instant messaging application | |
CN115576645B (en) | Virtual processor scheduling method and device, storage medium and electronic equipment | |
CN107632835B (en) | Application installation method and device | |
CN108958911B (en) | Process control method and device | |
CN107371222B (en) | Virtual card disabling method and device | |
CN112286687A (en) | Resource processing method and device | |
CN106201738B (en) | System broadcast calling method and device | |
CN110515623B (en) | Method and device for realizing graphic operation, electronic equipment and storage medium | |
CN105786561B (en) | Method and device for calling process | |
CN109586951B (en) | Method, device, electronic equipment and readable storage medium for implementing fault transfer | |
CN111666146A (en) | Multitask concurrent processing method and device | |
US11269699B2 (en) | Method and device for processing an application | |
CN116360979A (en) | Memory allocation method and device, electronic equipment and 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 |