[go: up one dir, main page]

TWI894013B - Resource allocation method and system - Google Patents

Resource allocation method and system

Info

Publication number
TWI894013B
TWI894013B TW113139094A TW113139094A TWI894013B TW I894013 B TWI894013 B TW I894013B TW 113139094 A TW113139094 A TW 113139094A TW 113139094 A TW113139094 A TW 113139094A TW I894013 B TWI894013 B TW I894013B
Authority
TW
Taiwan
Prior art keywords
resource
existing
priority
task
hardware
Prior art date
Application number
TW113139094A
Other languages
Chinese (zh)
Inventor
黃添壽
王紹宇
Original Assignee
技鋼科技股份有限公司
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 技鋼科技股份有限公司 filed Critical 技鋼科技股份有限公司
Priority to TW113139094A priority Critical patent/TWI894013B/en
Application granted granted Critical
Publication of TWI894013B publication Critical patent/TWI894013B/en

Links

Landscapes

  • Multi Processors (AREA)

Abstract

The present disclosure proposes a resource allocation method and system. The resource allocation method includes: determining a target resource requirement from candidate resource requirements according to a type of a designated job included in an input command, obtaining total available hardware resource according to occupied hardware resource of existing jobs and current available hardware resource when the current available hardware resource does not satisfy the target resource requirement and priorities of the existing jobs are lower than a priority of the designated job, allocating target resource satisfying the target resource requirement from the total available hardware resource to the designated job, and allocating first resource to a first existing job and second resource to a second existing job, respectively, when remaining resource of the total available hardware resource does not satisfy resource requirements of the existing jobs, wherein the first resource is lower than the second resource, and a priority of the first existing job is lower than a priority of the second existing job.

Description

資源分配方法及系統Resource allocation method and system

本發明係關於一種資源分配方法及系統。The present invention relates to a resource allocation method and system.

在傳統的軟體開發流程中,開發者多半使用個人電腦作為開發平台。然而,隨著專案規模不斷擴大,個人電腦的效能逐漸無法滿足需求。因此,業界常採用效能更強的工作站或伺服器作為開發平台。In traditional software development, developers typically use personal computers as their development platform. However, as project sizes continue to grow, the performance of personal computers is increasingly insufficient. Therefore, the industry often uses more powerful workstations or servers as development platforms.

然而,當開發環境從個人電腦遷移至多人共用的伺服器時,往往會遇到硬體資源分配不均的問題,影響開發效率及工作進度。However, when the development environment migrates from a personal computer to a shared server, uneven hardware resource allocation often occurs, impacting development efficiency and work progress.

鑒於上述,本發明提供一種解決上述問題的資源分配方法及系統。In view of the above, the present invention provides a resource allocation method and system to solve the above problems.

依據本發明一實施例的資源分配方法,以處理裝置執行,包含:根據輸入指令所包含的指定工作的類型從多筆候選資源需求中判斷目標資源需求;於當前可用硬體資源不滿足目標資源需求且多個既存工作的多個優先等級低於指定工作的優先等級時,收回該些既存工作的第一已佔用硬體資源,以根據第一已佔用硬體資源與當前可用硬體資源取得第一可用總硬體資源;將第一可用總硬體資源中滿足目標資源需求的目標資源分配給指定工作;以及當第一可用總硬體資源的除了目標資源外的第一剩餘硬體資源不滿足該些既存工作的資源需求時,從第一剩餘硬體資源中分配第一資源給該些既存工作中的第一既存工作,及將第一剩餘硬體資源中除了第一資源外的第二資源分配給該些既存工作中的至少一第二既存工作,其中第一既存工作的優先等級低於至少一第二既存工作的優先等級,且其中第二資源高於第一資源。According to an embodiment of the present invention, a resource allocation method is executed by a processing device, comprising: determining a target resource requirement from a plurality of candidate resource requirements according to the type of a designated task included in an input command; when the currently available hardware resources do not meet the target resource requirement and the priorities of the plurality of existing tasks are lower than the priority of the designated task, reclaiming the first occupied hardware resources of the existing tasks to obtain a first available total hardware resource based on the first occupied hardware resources and the currently available hardware resources; and allocating the first available total hardware resources that meet the target resource requirement to the first available total hardware resource. allocating the requested target resource to the designated task; and when first remaining hardware resources excluding the target resource of the first available total hardware resources do not meet the resource requirements of the existing tasks, allocating a first resource from the first remaining hardware resources to a first existing task among the existing tasks, and allocating a second resource excluding the first resource from the first remaining hardware resources to at least one second existing task among the existing tasks, wherein a priority of the first existing task is lower than a priority of the at least one second existing task, and wherein the second resource is higher than the first resource.

依據本發明一實施例的資源分配系統,包含:記憶裝置及處理裝置。記憶裝置用於儲存多筆候選資源需求。處理裝置連接於記憶裝置,處理裝置用於執行:根據輸入指令所包含的指定工作的類型從多筆候選資源需求中判斷目標資源需求;於當前可用硬體資源不滿足目標資源需求且多個既存工作的多個優先等級低於指定工作的優先等級時,收回該些既存工作的第一已佔用硬體資源,以根據第一已佔用硬體資源與當前可用硬體資源取得第一可用總硬體資源;將第一可用總硬體資源中滿足目標資源需求的目標資源分配給指定工作;以及當第一可用總硬體資源的除了目標資源外的第一剩餘硬體資源不滿足該些既存工作的資源需求時,從第一剩餘硬體資源中分配第一資源給該些既存工作中的第一既存工作,及將第一剩餘硬體資源中除了第一資源外的第二資源分配給該些既存工作中的至少一第二既存工作,其中第一既存工作的優先等級低於至少一第二既存工作的優先等級,且其中第二資源高於第一資源。According to an embodiment of the present invention, a resource allocation system includes: a memory device and a processing device. The memory device is used to store multiple candidate resource requirements. The processing device is connected to the memory device, and the processing device is used to execute: judging the target resource requirement from multiple candidate resource requirements according to the type of designated work included in the input instruction; when the currently available hardware resources do not meet the target resource requirement and the multiple priorities of multiple existing jobs are lower than the priority of the designated job, reclaiming the first occupied hardware resources of these existing jobs to obtain the first available total hardware resources based on the first occupied hardware resources and the currently available hardware resources; and allocating the target resource requirements that meet the target resource requirement from the first available total hardware resources. allocating target resources to designated tasks; and when first remaining hardware resources excluding the target resources of the first available total hardware resources do not meet the resource requirements of the existing tasks, allocating first resources from the first remaining hardware resources to a first existing task among the existing tasks, and allocating second resources excluding the first resources from the first remaining hardware resources to at least one second existing task among the existing tasks, wherein a priority of the first existing task is lower than a priority of the at least one second existing task, and wherein the second resource is higher than the first resource.

綜上所述,根據以上一或多個實施例的資源分配方法及系統可避免硬體資源分配不均的問題,確保較重要的工作可優先分配到足夠的硬體資源。因此,不論是將工作由個人電腦遷移至多人共用的伺服器,或是將工作由伺服器遷移至個人電腦,皆可使硬體資源被有效分配。In summary, the resource allocation method and system according to one or more of the above embodiments can avoid the problem of uneven hardware resource allocation and ensure that more important tasks are preferentially allocated sufficient hardware resources. Therefore, whether migrating tasks from a personal computer to a shared server or migrating tasks from a server to a personal computer, hardware resources can be effectively allocated.

以上之關於本揭露內容之說明及以下之實施方式之說明係用以示範與解釋本發明之精神與原理,並且提供本發明之專利申請範圍更進一步之解釋。The above description of the present disclosure and the following description of the embodiments are intended to demonstrate and explain the spirit and principles of the present invention, and to provide further explanation of the scope of the patent application of the present invention.

以下在實施方式中詳細敘述本發明之詳細特徵以及優點,其內容足以使任何熟習相關技藝者了解本發明之技術內容並據以實施,且根據本說明書所揭露之內容、申請專利範圍及圖式,任何熟習相關技藝者可輕易地理解本發明相關之目的及優點。以下之實施例係進一步詳細說明本發明之觀點,但非以任何觀點限制本發明之範疇。The following detailed description of the features and advantages of the present invention is sufficient to enable anyone skilled in the relevant art to understand the technical content of the present invention and implement it accordingly. Based on the disclosure, patent application scope, and drawings in this specification, anyone skilled in the relevant art can easily understand the relevant objectives and advantages of the present invention. The following examples are intended to further illustrate the concepts of the present invention in detail and are not intended to limit the scope of the present invention in any way.

請參考圖1,其中圖1係依據本發明一實施例所繪示的資源分配系統的方塊圖。如圖1所示,資源分配系統1包括記憶裝置11以及處理裝置12。記憶裝置11通訊或電性連接於處理裝置12。Please refer to FIG1 , which is a block diagram of a resource allocation system according to an embodiment of the present invention. As shown in FIG1 , the resource allocation system 1 includes a memory device 11 and a processing device 12. The memory device 11 is communicatively or electrically connected to the processing device 12.

記憶裝置11用於儲存多筆候選資源需求。候選資源需求可對應於不同的工作類型,且每個工作類型可對應於不同的硬體資源配置資訊。工作類型可包括多線程編譯(例如,C語言程式)、編譯過程中需同步下載程式碼之編譯情境(例如,Openbmc專案)、資料處理及人工智慧訓練。多線程編譯對應的硬體資源配置資訊可包括:64核心的中央處理器、8GB的動態隨機存取記憶體、50GB的固態硬碟及0核心的繪圖處理器。需同步下載程式碼之編譯情境的硬體資源配置資訊可包括:32核心的中央處理器、32GB的動態隨機存取記憶體、100GB的固態硬碟及0核心的繪圖處理器。資料處理及人工智慧訓練的硬體資源配置資訊可包括:8核心的中央處理器、12GB的動態隨機存取記憶體、50GB的固態硬碟及64核心的繪圖處理器。上述的工作類型及硬體資源配置資訊僅為示例,本發明不予以限制。記憶裝置11可包括一或多個記憶體,所述記憶體可為非揮發性記憶體(non-volatile memory,NVM),例如唯讀記憶體(read-only memory,ROM)、快閃記憶體及/或非揮發性隨機存取記憶體(non-volatile random access memory,NVRAM)等。The memory device 11 is used to store multiple candidate resource requirements. The candidate resource requirements may correspond to different work types, and each work type may correspond to different hardware resource configuration information. Work types may include multi-threaded compilation (e.g., C language programs), compilation scenarios requiring simultaneous code downloading during compilation (e.g., OpenBMC projects), data processing, and artificial intelligence training. Hardware resource configuration information corresponding to multi-threaded compilation may include: a 64-core CPU, 8GB of DRAM, a 50GB solid-state drive, and a 0-core graphics processor. The hardware resource configuration information for a compilation scenario requiring simultaneous code download may include: a 32-core CPU, 32GB of RAM, a 100GB SSD, and a 0-core GPU. The hardware resource configuration information for data processing and AI training may include: an 8-core CPU, 12GB of RAM, a 50GB SSD, and a 64-core GPU. The above workload types and hardware resource configuration information are examples only and are not intended to limit the present invention. The memory device 11 may include one or more memories, which may be non-volatile memories (NVM), such as read-only memory (ROM), flash memory, and/or non-volatile random access memory (NVRAM).

處理裝置12用於根據指定工作的類型及候選資源需求中的對應者分配硬體資源。所述硬體資源可為個人電腦或伺服器等運算裝置的硬體資源,以下是以伺服器為例進行說明,但本發明不以此為限。處理裝置12可包括一或多個處理器,所述處理器例如為中央處理器、繪圖處理器、微控制器、可程式化邏輯控制器或其他具有訊號處理功能的處理器。The processing device 12 is used to allocate hardware resources based on the type of designated task and the corresponding resource requirements in the candidate resource requirements. These hardware resources can be those of a computing device such as a personal computer or a server. The following description uses a server as an example, but the present invention is not limited thereto. The processing device 12 can include one or more processors, such as a central processing unit (CPU), a graphics processor (GPU), a microcontroller (MCU), a programmable logic controller (PLC), or other processors with signal processing capabilities.

請一併參考圖1及圖2,其中圖2係依據本發明一實施例所繪示的資源分配方法的流程圖。資源分配方法可由如圖1所示的處理裝置12執行。如圖2所示,資源分配方法包括:步驟S101:根據輸入指令所包含的指定工作的類型從多筆候選資源需求中判斷目標資源需求;步驟S103:於當前可用硬體資源不滿足目標資源需求且多個既存工作的多個優先等級低於指定工作的優先等級時,收回該些既存工作的第一已佔用硬體資源,以根據第一已佔用硬體資源與當前可用硬體資源取得第一可用總硬體資源;步驟S105: 將第一可用總硬體資源中滿足目標資源需求的目標資源分配給指定工作;以及步驟S107:當第一可用總硬體資源的除了目標資源外的第一剩餘硬體資源不滿足該些既存工作的資源需求時,從第一剩餘硬體資源中分配第一資源給該些既存工作中的第一既存工作,及將第一剩餘硬體資源中除了第一資源外的第二資源分配給該些既存工作中的至少一第二既存工作。Please refer to Figures 1 and 2 together, wherein Figure 2 is a flow chart of a resource allocation method according to an embodiment of the present invention. The resource allocation method can be executed by the processing device 12 shown in Figure 1. As shown in Figure 2, the resource allocation method includes: Step S101: determining a target resource requirement from a plurality of candidate resource requirements based on the type of designated work included in the input command; Step S103: when the currently available hardware resources do not meet the target resource requirement and the plurality of priorities of the plurality of existing jobs are lower than the priority of the designated work, reclaiming the first occupied hardware resources of the existing jobs to obtain a first available total hardware resource based on the first occupied hardware resources and the currently available hardware resources; Step S105: Allocating target resources that meet target resource requirements from the first available total hardware resources to the designated task; and step S107: when first remaining hardware resources excluding the target resources from the first available total hardware resources do not meet resource requirements of the existing tasks, allocating first resources from the first remaining hardware resources to a first existing task among the existing tasks, and allocating second resources excluding the first resources from the first remaining hardware resources to at least one second existing task among the existing tasks.

於步驟S101,處理裝置12取得使用者輸入的輸入指令,且輸入指令可包括指定工作的類型。處理裝置12根據指定工作的類型從記憶裝置11儲存的候選資源需求中選擇一者作為目標資源需求。舉例而言,指定工作的類型為多線程編譯,目標資源需求為64核心的中央處理器、8GB的動態隨機存取記憶體、50GB的固態硬碟及0核心的繪圖處理器。In step S101, processing device 12 receives an input command from a user, which may include a designated task type. Based on the designated task type, processing device 12 selects one of the candidate resource requirements stored in memory device 11 as a target resource requirement. For example, if the designated task type is multi-threaded compilation, the target resource requirements are a 64-core CPU, 8GB of DRAM, a 50GB SSD, and a 0-core graphics processor.

於步驟S103,當處理裝置12判斷伺服器的當前可用硬體資源不滿足目標資源需求且伺服器正在執行的既存工作的優先等級皆低於指定工作的優先等級時,處理裝置12收回該些既存工作的第一已佔用硬體資源,以根據第一已佔用硬體資源與當前可用硬體資源取得第一可用總硬體資源。第一已佔用硬體資源可為用於執行所有既存工作的硬體資源之總和,當前可用硬體資源可為閒置資源。以中央處理器為例,若當前可用硬體資源指示中央處理器的可用核心數量為零時,第一可用總硬體資源為第一已佔用硬體資源;若當前可用硬體資源指示中央處理器的可用核心數量大於零時,第一可用總硬體資源為第一已佔用硬體資源與當前可用硬體資源之和。In step S103, when the processing device 12 determines that the server's currently available hardware resources do not meet the target resource requirements and that the priorities of all existing tasks currently being executed by the server are lower than the priority of the designated task, the processing device 12 reclaims the first occupied hardware resources of these existing tasks to obtain a first total available hardware resource based on the first occupied hardware resources and the currently available hardware resources. The first occupied hardware resource may be the sum of the hardware resources used to execute all existing tasks, and the currently available hardware resources may be idle resources. Taking the central processing unit (CPU) as an example, if the currently available hardware resources indicate that the number of available cores of the CPU is zero, the first total available hardware resources are the first occupied hardware resources. If the currently available hardware resources indicate that the number of available cores of the CPU is greater than zero, the first total available hardware resources are the sum of the first occupied hardware resources and the currently available hardware resources.

於步驟S105,處理裝置12基於指定工作的高於既存工作的優先等級,依據指定工作所需的目標資源需求,將第一可用總硬體資源中滿足目標資源需求的目標資源分配給指定工作。進一步而言,目標資源可被分配給指定工作的容器(container),指定工作的容器可被啟動以執行指定工作。In step S105, the processing device 12 allocates target resources from the first available total hardware resources that meet the target resource requirements of the designated task, based on the designated task's higher priority than existing tasks. Furthermore, the target resources may be allocated to a container for the designated task, which may then be activated to execute the designated task.

於步驟S107,在將目標資源分配給指定工作後,當處理裝置12判斷伺服器的第一可用總硬體資源的除了目標資源外的第一剩餘硬體資源不滿足該些既存工作的資源需求,且該些既存工作中的第一既存工作的優先等級低於該些既存工作中的至少一第二既存工作的優先等級時,處理裝置12從第一剩餘硬體資源中分配第一資源給第一既存工作,及將第一剩餘硬體資源中除了第一資源外的第二資源分配給第二既存工作,其中第二資源高於第一資源。In step S107, after allocating the target resource to the designated task, when the processing device 12 determines that the first remaining hardware resources of the server's first total available hardware resources excluding the target resource do not meet the resource requirements of the existing tasks, and the priority of the first existing task among the existing tasks is lower than the priority of at least one second existing task among the existing tasks, the processing device 12 allocates the first resource from the first remaining hardware resources to the first existing task, and allocates the second resource excluding the first resource from the first remaining hardware resources to the second existing task, where the second resource is higher than the first resource.

具體而言,在將第一可用總硬體資源中的目標資源分配給指定工作後,伺服器剩餘的硬體資源為第一剩餘硬體資源,當第一剩餘硬體資源無法滿足所有既存工作的資源需求時,處理裝置12將第一剩餘硬體資源中的第一資源分配給第一既存工作,及將第一剩餘硬體資源中除了第一資源外的剩餘的第二資源分配給第二既存工作。第一資源可為最低配置資源。於一實施例中,當第二既存工作的數量為多個時,處理裝置12可將第二資源平均分配給第二既存工作。Specifically, after allocating target resources from the first available total hardware resources to a designated task, the remaining hardware resources on the server are first remaining hardware resources. If the first remaining hardware resources cannot meet the resource requirements of all existing tasks, the processing device 12 allocates first resources from the first remaining hardware resources to the first existing task and allocates remaining second resources from the first remaining hardware resources, excluding the first resources, to a second existing task. The first resources may be minimum allocation resources. In one embodiment, if there are multiple second existing tasks, the processing device 12 may evenly distribute the second resources among the second existing tasks.

據此,根據以上一或多個實施例的資源分配方法及系統可避免硬體資源分配不均的問題,確保較重要的工作可優先分配到足夠的硬體資源。因此,不論是將工作由個人電腦遷移至多人共用的伺服器,或是將工作由伺服器遷移至個人電腦,皆可使硬體資源被有效分配。Thus, the resource allocation method and system according to one or more of the above embodiments can avoid the problem of uneven hardware resource allocation and ensure that more important tasks are preferentially allocated sufficient hardware resources. Therefore, whether migrating tasks from a personal computer to a shared server or migrating tasks from a server to a personal computer, hardware resources can be effectively allocated.

請一併參考圖1及圖3,其中圖3係依據本發明一實施例所繪示的資源分配方法中指定工作的優先等級不高於既存工作的資源分配方式的流程圖。圖3所示的步驟可由如圖1所示的處理裝置12執行。如圖3所示,資源分配方法更包括:步驟S201:於當前可用硬體資源不滿足目標資源需求且該些既存工作的該些優先等級不低於指定工作的優先等級時,收回該些既存工作的第二已佔用硬體資源,以根據第二已佔用硬體資源與當前可用硬體資源取得第二可用總硬體資源;步驟S203:從第二可用總硬體資源分配至少一第三資源給該些既存工作之中具有該些優先等級之中的最高優先等級的至少一第三既存工作;以及步驟S205:從第二可用總硬體資源中除了至少一第三資源外的第二剩餘硬體資源分配部分資源給指定工作及至少一第四資源給至少一第四既存工作。Please refer to FIG. 1 and FIG. 3 , wherein FIG. 3 is a flowchart illustrating a resource allocation method according to an embodiment of the present invention for allocating resources to a task whose priority is not higher than that of an existing task. The steps shown in FIG. 3 may be performed by the processing device 12 shown in FIG. 1 . As shown in FIG3 , the resource allocation method further includes: step S201: when currently available hardware resources do not meet target resource requirements and the priorities of the existing tasks are not lower than the priority of the designated task, reclaiming the second occupied hardware resources of the existing tasks to obtain a second total available hardware resource based on the second occupied hardware resources and the currently available hardware resources; step S203: allocating at least one third resource from the second total available hardware resources to at least one third existing task having the highest priority among the priorities among the existing tasks; and step S205: allocating a portion of the second remaining hardware resources excluding the at least one third resource from the second total available hardware resources to the designated task and at least one fourth resource to at least one fourth existing task.

在處理裝置12取得使用者輸入的輸入指令後,於步驟S201,當處理裝置12判斷伺服器的當前可用硬體資源不滿足目標資源需求且伺服器正在執行的既存工作的優先等級不低於指定工作的優先等級時,處理裝置12收回該些既存工作的第二已佔用硬體資源,以根據第二已佔用硬體資源與當前可用硬體資源取得第二可用總硬體資源。第二已佔用硬體資源可為用於執行所有既存工作的硬體資源之總和,當前可用硬體資源可為閒置資源。以中央處理器為例,若當前可用硬體資源指示中央處理器的可用核心數量為零時,第二可用總硬體資源為第二已佔用硬體資源;若當前可用硬體資源指示中央處理器的可用核心數量大於零時,第二可用總硬體資源為第二已佔用硬體資源與當前可用硬體資源之和。After the processing device 12 receives the input command from the user, in step S201, if the processing device 12 determines that the server's currently available hardware resources do not meet the target resource requirements and the priority of existing jobs being executed by the server is not lower than the priority of the designated job, the processing device 12 reclaims the second occupied hardware resources of these existing jobs to obtain a second total available hardware resource based on the second occupied hardware resources and the currently available hardware resources. The second occupied hardware resources may be the sum of the hardware resources used to execute all existing jobs, and the currently available hardware resources may be idle resources. Taking the central processing unit (CPU) as an example, if the currently available hardware resources indicate that the number of available cores of the CPU is zero, the second total available hardware resources are the second occupied hardware resources. If the currently available hardware resources indicate that the number of available cores of the CPU is greater than zero, the second total available hardware resources are the sum of the second occupied hardware resources and the currently available hardware resources.

於步驟S203,處理裝置12依據既存工作中具有最高優先等級的第三既存工作,將第二可用總硬體資源中滿足第三既存工作的第三資源分配給第三既存工作。進一步而言,第三資源可被分配給第三既存工作的容器,第三既存工作的容器可被啟動以執行第三既存工作。In step S203, the processing device 12 allocates a third resource from the second available total hardware resources that satisfies the third existing task to the third existing task based on the third existing task having the highest priority among the existing tasks. Furthermore, the third resource may be allocated to a container for the third existing task, and the container for the third existing task may be activated to execute the third existing task.

於步驟S205,在將第三資源分配給第三既存工作後,處理裝置12將第二可用總硬體資源的除了第三資源外的硬體資源分配部分資源給指定工作,及分配第四資源給該些既存工作中的第四既存工作。In step S205, after allocating the third resource to the third existing task, the processing device 12 allocates a portion of the hardware resources of the second available total hardware resources excluding the third resource to the designated task, and allocates the fourth resource to the fourth existing task among the existing tasks.

具體而言,在將第二可用總硬體資源中的第三資源分配給具有最高優先等級的第三既存工作後,伺服器剩餘的硬體資源為第二剩餘硬體資源。當指定工作的優先等級低於第四既存工作的優先等級時,處理裝置12分配給指定工作的部分資源低於分配給第四既存工作的第四資源;當指定工作的優先等級等於第四既存工作的優先等級時,處理裝置12分配給指定工作的部分資源等於分配給第四既存工作的第四資源。Specifically, after allocating the third resource from the second available total hardware resources to the third existing job with the highest priority, the remaining hardware resources on the server are the second remaining hardware resources. When the priority of the designated job is lower than the priority of the fourth existing job, the portion of resources allocated by processing device 12 to the designated job is lower than the fourth resource allocated to the fourth existing job. When the priority of the designated job is equal to the priority of the fourth existing job, the portion of resources allocated by processing device 12 to the designated job is equal to the fourth resource allocated to the fourth existing job.

於一實施例中,當指定工作的優先等級及第三既存工作的優先等級皆為最高優先等級時,處理裝置12可從第二可用總硬體資源分配滿足指定工作的目標資源需求給指定工作及分配滿足第三既存工作的硬體資源給第三既存工作。當剩餘的硬體資源不滿足其他既存工作時,處理裝置12可分配最低配置資源給既存工作中具有最低優先等級的一或多者,及將剩餘的硬體資源平均分配給剩餘的既存工作。In one embodiment, when both the priority of the designated task and the priority of the third existing task are the highest, the processing device 12 may allocate the target resource requirements of the designated task from the second available total hardware resources to the designated task and allocate the hardware resources required to meet the requirements of the third existing task to the third existing task. If the remaining hardware resources are insufficient to meet the requirements of the other existing tasks, the processing device 12 may allocate the minimum allocation resources to one or more of the existing tasks with the lowest priority and evenly distribute the remaining hardware resources among the remaining existing tasks.

另外,當指定工作的優先等級及第三既存工作的優先等級皆為最高優先等級,且第二可用總硬體資源不滿足目標資源需求及第三既存工作的資源需求時,處理裝置12可將第二可用總硬體資源平均分配給指定工作及第三既存工作。In addition, when the priority of the designated task and the priority of the third existing task are both the highest priority and the second total available hardware resources do not meet the target resource requirements and the resource requirements of the third existing task, the processing device 12 may evenly distribute the second total available hardware resources to the designated task and the third existing task.

另需特別說明的是,上述的第三既存工作及第四既存工作各自的數量可為一或多個,本發明不予以限制。並且,取決於既存工作佔用的硬體資源,第一已佔用硬體資源及第二已佔用硬體資源可彼此相同或相異,本發明不予以限制。It should be noted that the number of the third and fourth existing tasks can be one or more, and the present invention does not limit this. Furthermore, depending on the hardware resources occupied by the existing tasks, the first and second occupied hardware resources can be the same or different, and the present invention does not limit this.

此外,資源分配方法可更包括根據使用者指令判斷指定工作的優先等級。具體而言,使用者指令可指示指定工作的優先等級,處理裝置12可接收使用者指令,及根據使用者指令指示的優先等級執行圖2的步驟S103及圖3的步驟S201。並且,既存工作的優先等級亦可為根據使用者指令判斷。Furthermore, the resource allocation method may further include determining the priority of a designated task based on a user instruction. Specifically, the user instruction may indicate the priority of the designated task. The processing device 12 may receive the user instruction and execute step S103 of FIG. 2 and step S201 of FIG. 3 based on the priority indicated in the user instruction. Furthermore, the priority of an existing task may also be determined based on the user instruction.

此外,在以上一或多個實施例的資源分配方法及系統中,當有新的指定工作加入,或是既存工作完成時,處理裝置12可產生重新分配資源的中斷,以再次執行圖的步驟S103及/或圖3的步驟S201。In addition, in the resource allocation method and system of one or more of the above embodiments, when a new designated task is added or an existing task is completed, the processing device 12 may generate an interrupt to reallocate resources to execute step S103 of the figure and/or step S201 of Figure 3 again.

綜上所述,根據以上一或多個實施例的資源分配方法及系統可避免硬體資源分配不均的問題,確保較重要的工作可優先分配到足夠的硬體資源。因此,不論是將工作由個人電腦遷移至多人共用的伺服器,或是將工作由伺服器遷移至個人電腦,皆可使硬體資源被有效分配。In summary, the resource allocation method and system according to one or more of the above embodiments can avoid the problem of uneven hardware resource allocation and ensure that more important tasks are preferentially allocated sufficient hardware resources. Therefore, whether migrating tasks from a personal computer to a shared server or migrating tasks from a server to a personal computer, hardware resources can be effectively allocated.

雖然本發明以前述之實施例揭露如上,然其並非用以限定本發明。在不脫離本發明之精神和範圍內,所為之更動與潤飾,均屬本發明之專利保護範圍。關於本發明所界定之保護範圍請參考所附之申請專利範圍。Although the present invention is disclosed above with reference to the aforementioned embodiments, they are not intended to limit the present invention. Any modifications and enhancements that do not depart from the spirit and scope of the present invention are within the scope of patent protection of the present invention. Please refer to the attached patent application for the scope of protection defined by the present invention.

1:資源分配系統 11:記憶裝置 12:處理裝置 S101,S103,S105,S107,S201,S203,S205:步驟 1: Resource Allocation System 11: Memory Device 12: Processing Device S101, S103, S105, S107, S201, S203, S205: Steps

圖1係依據本發明一實施例所繪示的資源分配系統的方塊圖。 圖2係依據本發明一實施例所繪示的資源分配方法的流程圖。 圖3係依據本發明一實施例所繪示的資源分配方法中指定工作的優先等級不高於既存工作的資源分配方式的流程圖。 Figure 1 is a block diagram of a resource allocation system according to an embodiment of the present invention. Figure 2 is a flow chart of a resource allocation method according to an embodiment of the present invention. Figure 3 is a flow chart of a resource allocation method according to an embodiment of the present invention, illustrating a method for allocating resources in which the priority of a designated task is no higher than that of an existing task.

S101,S103,S105,S107:步驟 S101, S103, S105, S107: Steps

Claims (8)

一種資源分配方法,以一處理裝置執行,包含:根據一輸入指令所包含的一指定工作的類型從多筆候選資源需求中判斷一目標資源需求;當一當前可用硬體資源不滿足該目標資源需求且多個既存工作的多個優先等級低於該指定工作的優先等級時,收回該些既存工作的一第一已佔用硬體資源,以根據該第一已佔用硬體資源與該當前可用硬體資源取得一第一可用總硬體資源;將該第一可用總硬體資源中滿足該目標資源需求的一目標資源分配給該指定工作;以及當該第一可用總硬體資源的除了該目標資源外的一第一剩餘硬體資源不滿足該些既存工作的資源需求時,從該第一剩餘硬體資源中分配一第一資源給該些既存工作中的一第一既存工作,及將該第一剩餘硬體資源中除了該第一資源外的一第二資源分配給該些既存工作中的至少一第二既存工作,其中該第一既存工作的優先等級低於該至少一第二既存工作的優先等級,且其中該第二資源高於該第一資源,其中該資源分配方法更包含:當該當前可用硬體資源不滿足該目標資源需求且該些既存工作的該些優先等級不低於該指定工作的該優先等級時,收回該些既存工作的一第二已佔用硬體資源,以根據該第二已佔用硬體資源與該當前可用硬體資源取得一第二可用總硬體資源;從該第二可用總硬體資源分配至少一第三資源給該些既存工作之中具有該些優先等級之中的最高優先等級的至少一第三既存工作;以及從該第二可用總硬體資源中除了該至少一第三資源外的一第二剩餘硬體資源分配一部分資源給該指定工作及至少一第四資源給至少一第四既存工作,其中當該指定工作的該優先等級低於該至少一第四既存工作的優先等級時,該部分資源低於該至少一第四資源,及當該指定工作的該優先等級等於該至少一第四既存工作的該優先等級時,該部分資源等於該至少一第四資源。A resource allocation method is executed by a processing device, comprising: determining a target resource requirement from a plurality of candidate resource requirements according to a type of a designated task included in an input command; when a currently available hardware resource does not meet the target resource requirement and a plurality of priorities of a plurality of existing tasks are lower than the priority of the designated task, reclaiming a first occupied hardware resource of the existing tasks to obtain a first available total hardware resource based on the first occupied hardware resource and the currently available hardware resource; allocating the first available total hardware resource that meets the target resource requirement to the first available total hardware resource; allocating a target resource of the target resource requirement to the designated task; and when a first remaining hardware resource of the first available total hardware resources excluding the target resource does not satisfy the resource requirements of the existing tasks, allocating a first resource from the first remaining hardware resource to a first existing task among the existing tasks, and allocating a second resource of the first remaining hardware resource excluding the first resource to at least one second existing task among the existing tasks, wherein the priority of the first existing task is lower than the priority of the at least one second existing task and wherein the second resource is higher than the first resource, wherein the resource allocation method further comprises: when the currently available hardware resources do not meet the target resource requirement and the priorities of the existing tasks are not lower than the priority of the designated task, reclaiming a second occupied hardware resource of the existing tasks to obtain a second available total hardware resource based on the second occupied hardware resource and the currently available hardware resource; allocating at least a third resource from the second available total hardware resource to the task with the highest priority among the existing tasks; at least one third existing job with a priority level; and allocating a portion of resources to the designated job and at least one fourth resource to at least one fourth existing job from a second remaining hardware resource excluding the at least one third resource in the second available total hardware resources, wherein when the priority level of the designated job is lower than the priority level of the at least one fourth existing job, the portion of resources is lower than the at least one fourth resource, and when the priority level of the designated job is equal to the priority level of the at least one fourth existing job, the portion of resources is equal to the at least one fourth resource. 如請求項1所述的資源分配方法,其中該至少一第二既存工作係多個第二既存工作,將該第一剩餘硬體資源中除了該第一資源外的該第二資源分配給該些既存工作中的該至少一第二既存工作包含:將該第二資源平均分配給該些第二既存工作。The resource allocation method as described in claim 1, wherein the at least one second existing task is a plurality of second existing tasks, and allocating the second resources other than the first resources in the first remaining hardware resources to the at least one second existing task among the existing tasks includes: evenly allocating the second resources to the second existing tasks. 如請求項1所述的資源分配方法,更包含:根據一使用者指令判斷該指定工作的該優先等級。The resource allocation method as described in claim 1 further includes: determining the priority level of the designated task based on a user instruction. 如請求項1所述的資源分配方法,其中該指定工作的該類型包含多線程編譯、同步執行編譯及下載程式碼、資料處理及人工智慧訓練中的至少一者。The resource allocation method of claim 1, wherein the type of the designated task includes at least one of multi-threaded compilation, simultaneous compilation and code downloading, data processing, and artificial intelligence training. 一種資源分配系統,包含:一記憶裝置,用於儲存多筆候選資源需求;以及一處理裝置,連接於該記憶裝置,該處理裝置用於執行:根據一輸入指令所包含的一指定工作的類型從該些候選資源需求中判斷一目標資源需求;當一當前可用硬體資源不滿足該目標資源需求且多個既存工作的多個優先等級低於該指定工作的優先等級時,收回該些既存工作的一第一已佔用硬體資源,以根據該第一已佔用硬體資源與該當前可用硬體資源取得一第一可用總硬體資源;將該第一可用總硬體資源中滿足該目標資源需求的一目標資源分配給該指定工作;以及當該第一可用總硬體資源的除了該目標資源外的一第一剩餘硬體資源不滿足該些既存工作的資源需求時,從該第一剩餘硬體資源中分配一第一資源給該些既存工作中的一第一既存工作,及將該第一剩餘硬體資源中除了該第一資源外的一第二資源分配給該些既存工作中的至少一第二既存工作,其中該第一既存工作的優先等級低於該至少一第二既存工作的優先等級,且其中該第二資源高於該第一資源,其中該處理裝置更用於執行:當該當前可用硬體資源不滿足該目標資源需求且該些既存工作的該些優先等級不低於該指定工作的該優先等級時,收回該些既存工作的一第二已佔用硬體資源,以根據該第二已佔用硬體資源與該當前可用硬體資源取得一第二可用總硬體資源;從該第二可用總硬體資源分配至少一第三資源給該些既存工作之中具有該些優先等級之中的最高優先等級的至少一第三既存工作;以及從該第二可用總硬體資源中除了該至少一第三資源外的一第二剩餘硬體資源分配一部分資源給該指定工作及至少一第四資源給至少一第四既存工作,其中當該指定工作的該優先等級低於該至少一第四既存工作的優先等級時,該部分資源低於該至少一第四資源,及當該指定工作的該優先等級等於該至少一第四既存工作的該優先等級時,該部分資源等於該至少一第四資源。A resource allocation system includes: a memory device for storing a plurality of candidate resource requirements; and a processing device connected to the memory device, the processing device being configured to: determine a target resource requirement from the candidate resource requirements based on a type of a designated task included in an input instruction; and when a currently available hardware resource does not meet the target resource requirement and a plurality of priorities of a plurality of existing tasks are lower than the priority of the designated task, reclaim a first occupied hardware resource of the existing tasks to obtain a target resource requirement based on the first occupied hardware resource and the currently available hardware resource. a first available total hardware resource; allocating a target resource that meets the target resource requirement from the first available total hardware resource to the designated task; and when a first remaining hardware resource of the first available total hardware resource excluding the target resource does not meet the resource requirements of the existing tasks, allocating a first resource from the first remaining hardware resource to a first existing task among the existing tasks, and allocating a second resource from the first remaining hardware resource excluding the first resource to at least one second existing task among the existing tasks, wherein the priority of the first existing task is the priority of the first existing task. The priority of the at least one second existing job is lower than the priority of the at least one second existing job, and the second resource is higher than the first resource, wherein the processing device is further configured to: when the currently available hardware resources do not meet the target resource requirement and the priorities of the existing jobs are not lower than the priority of the designated job, reclaim a second occupied hardware resource of the existing jobs to obtain a second available total hardware resource based on the second occupied hardware resource and the currently available hardware resource; and allocate at least one third resource from the second available total hardware resource to the existing jobs having the second occupied hardware resource. at least one third existing job of the highest priority among the priorities; and allocating a portion of resources to the designated job and at least one fourth resource to at least one fourth existing job from a second remaining hardware resource excluding the at least one third resource in the second available total hardware resources, wherein when the priority of the designated job is lower than the priority of the at least one fourth existing job, the portion of resources is lower than the at least one fourth resource, and when the priority of the designated job is equal to the priority of the at least one fourth existing job, the portion of resources is equal to the at least one fourth resource. 如請求項5所述的資源分配系統,其中該至少一第二既存工作係多個第二既存工作,該處理裝置係將該第二資源平均分配給該些第二既存工作。The resource allocation system as described in claim 5, wherein the at least one second existing task is a plurality of second existing tasks, and the processing device evenly distributes the second resource to the second existing tasks. 如請求項5所述的資源分配系統,其中該處理裝置更用於根據一使用者指令判斷該指定工作的該優先等級。The resource allocation system as described in claim 5, wherein the processing device is further configured to determine the priority of the designated task based on a user instruction. 如請求項5所述的資源分配系統,其中該指定工作的該類型包含多線程編譯、同步執行編譯及下載程式碼、資料處理及人工智慧訓練中的至少一者。The resource allocation system of claim 5, wherein the type of the designated task includes at least one of multi-threaded compilation, concurrent compilation and code downloading, data processing, and artificial intelligence training.
TW113139094A 2024-10-15 2024-10-15 Resource allocation method and system TWI894013B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
TW113139094A TWI894013B (en) 2024-10-15 2024-10-15 Resource allocation method and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
TW113139094A TWI894013B (en) 2024-10-15 2024-10-15 Resource allocation method and system

Publications (1)

Publication Number Publication Date
TWI894013B true TWI894013B (en) 2025-08-11

Family

ID=97524284

Family Applications (1)

Application Number Title Priority Date Filing Date
TW113139094A TWI894013B (en) 2024-10-15 2024-10-15 Resource allocation method and system

Country Status (1)

Country Link
TW (1) TWI894013B (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
TW201818244A (en) * 2016-11-08 2018-05-16 香港商阿里巴巴集團服務有限公司 Method, device and system for applying cluster resource allocation in cloud environment
US20190034227A1 (en) * 2017-07-26 2019-01-31 Bank Of America Corporation System and method of task execution
US20200026569A1 (en) * 2017-05-04 2020-01-23 Salesforce.Com, Inc. Systems, methods, and apparatuses for implementing a scheduler and workload manager with cyclical service level target (slt) optimization
CN111064746A (en) * 2019-12-30 2020-04-24 深信服科技股份有限公司 Resource allocation method, device, equipment and storage medium
TW202425597A (en) * 2022-12-09 2024-06-16 財團法人工業技術研究院 System, apparatus and method for cloud resource allocation

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
TW201818244A (en) * 2016-11-08 2018-05-16 香港商阿里巴巴集團服務有限公司 Method, device and system for applying cluster resource allocation in cloud environment
US20200026569A1 (en) * 2017-05-04 2020-01-23 Salesforce.Com, Inc. Systems, methods, and apparatuses for implementing a scheduler and workload manager with cyclical service level target (slt) optimization
US20190034227A1 (en) * 2017-07-26 2019-01-31 Bank Of America Corporation System and method of task execution
CN111064746A (en) * 2019-12-30 2020-04-24 深信服科技股份有限公司 Resource allocation method, device, equipment and storage medium
TW202425597A (en) * 2022-12-09 2024-06-16 財團法人工業技術研究院 System, apparatus and method for cloud resource allocation

Similar Documents

Publication Publication Date Title
US11720993B2 (en) Dynamic kernel memory space allocation
CN102985910B (en) To the system and method for garbage collection
CN107851004B (en) Method and apparatus for executing instructions on a Graphics Processing Unit (GPU)
CN110399217B (en) A memory resource allocation method, device and device
US9081694B2 (en) Systems and methods for asymmetric multiprocessing
CN101221514B (en) Method, processor and system for selecting the architecture level to which a processor appears to conform
US10261918B2 (en) Process running method and apparatus
TW201301029A (en) Memory manager with enhanced application metadata
US10846138B2 (en) Allocating resources of a memory fabric
US20250005705A1 (en) Register compaction with early release
KR20210007417A (en) Multi-core system and controlling operation of the same
CN118312464B (en) Data management method and data management system
CN119690862A (en) Memory allocation method, device, electronic device and non-volatile storage medium
CN110502334A (en) Bandwidth-aware task stealing method, system and chip based on hybrid memory architecture
TW201432571A (en) Technique for saving and restoring thread group operating state
CN110275869A (en) A flat file processing method and related device
CN110569122A (en) Multi-processor system, multi-core processing device and method of operation thereof
TWI894013B (en) Resource allocation method and system
CN115098244B (en) Distribution method of kernel stack, electronic equipment, chip and storage medium
CN112783651B (en) Load balancing scheduling method, medium and device for vGPU of cloud platform
US20090187911A1 (en) Computer device with reserved memory for priority applications
CN118409871B (en) Data processing method, product, server and medium
US12541813B2 (en) Dynamic kernel memory space allocation
CN114741194B (en) I/O request processing method and device
CN116450055B (en) Method and system for distributing storage area between multi-processing cards