TWI647619B - Method for performing hardware resource management in an electronic device, and corresponding electronic device - Google Patents

Method for performing hardware resource management in an electronic device, and corresponding electronic device Download PDF

Info

Publication number
TWI647619B
TWI647619B TW106129241A TW106129241A TWI647619B TW I647619 B TWI647619 B TW I647619B TW 106129241 A TW106129241 A TW 106129241A TW 106129241 A TW106129241 A TW 106129241A TW I647619 B TWI647619 B TW I647619B
Authority
TW
Taiwan
Prior art keywords
electronic device
variable
shared
data
storage area
Prior art date
Application number
TW106129241A
Other languages
Chinese (zh)
Other versions
TW201913371A (en
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 TW106129241A priority Critical patent/TWI647619B/en
Application granted granted Critical
Publication of TWI647619B publication Critical patent/TWI647619B/en
Publication of TW201913371A publication Critical patent/TW201913371A/en

Links

Abstract

本發明提供一種用來於電子裝置中進行硬體資源管理之方法及對應的電子裝置。該方法包含:利用該電子裝置中之一微處理器執行一組程式碼之至少一部分,以控制該電子裝置,其中該電子裝置之多個運作包含一預定運作,該組程式碼包含用來控制該預定運作之一預定程式模組,該預定程式模組包含一局部程式,且該局部程式提供一變數存取服務予該預定程式模組;以及利用該微處理器執行該局部程式,以控制該電子裝置進行該預定運作。The present invention provides a method and corresponding electronic device for performing hardware resource management in an electronic device. The method includes controlling, by the microprocessor of one of the electronic devices, at least a portion of a set of code to control the electronic device, wherein the plurality of operations of the electronic device include a predetermined operation, the set of code included for controlling a predetermined program module, the predetermined program module includes a partial program, and the partial program provides a variable access service to the predetermined program module; and the partial program is executed by the microprocessor to control The electronic device performs the predetermined operation.

Description

用來於一電子裝置中進行硬體資源管理之方法以及對應的電子裝置Method for performing hardware resource management in an electronic device and corresponding electronic device

本發明係有關於電子裝置的實施,尤指一種用來於一電子裝置中進行硬體資源管理之方法以及對應的電子裝置。The present invention relates to the implementation of an electronic device, and more particularly to a method for performing hardware resource management in an electronic device and a corresponding electronic device.

由於程式記憶體(program memory)諸如指令記憶體(instruction memory)的價格通常很高、且由於常被應用於一電子裝置之微處理器的最大定址範圍是有限的,例如「8051」型微處理器之最大定址範圍為16位元(bit),故微處理器只能使用(程式記憶體中之)64千位元組(kilobyte, KB)的儲存空間。在這樣的架構下,硬體資源相當有限。例如:當該電子裝置之設計者計畫要賦予該電子裝置很多功能時,64千位元組的大小往往是不足的,這導致有些功能必須被捨棄,使得在有限的製造成本之控管下,電子裝置的功能的多樣性無法提昇。因此,需要一種新穎的方法及記憶體存取架構,以在沒有副作用或較不可能帶來副作用之狀況下提昇電子裝置的功能的多樣性。Since the price of a program memory such as an instruction memory is usually high, and the maximum address range of a microprocessor that is often applied to an electronic device is limited, for example, "8051" type micro processing. The maximum address range of the device is 16 bits, so the microprocessor can only use the storage space of 64 kilobytes (KB) in the program memory. Under such a framework, hardware resources are quite limited. For example, when the designer of the electronic device plans to give the electronic device a lot of functions, the size of the 64 kilobytes is often insufficient, which causes some functions to be discarded, so that under the control of limited manufacturing costs The diversity of functions of electronic devices cannot be improved. Therefore, there is a need for a novel method and memory access architecture to enhance the variety of functions of electronic devices without side effects or with less potential side effects.

本發明之一目的在於提供一種用來於一電子裝置中進行硬體資源管理之方法以及對應的電子裝置,以解決上述問題。An object of the present invention is to provide a method for performing hardware resource management in an electronic device and a corresponding electronic device to solve the above problems.

本發明之另一目的在於提供一種用來於一電子裝置中進行硬體資源管理之方法以及對應的電子裝置,以減少該電子裝置的至少一程式模組(諸如一或多個程式模組)中之每一程式模組之機器碼量(machine code size)。Another object of the present invention is to provide a method for hardware resource management in an electronic device and corresponding electronic device to reduce at least one program module (such as one or more program modules) of the electronic device. The machine code size of each program module.

本發明之又一目的在於提供一種用來於一電子裝置中進行硬體資源管理之方法以及對應的電子裝置,以在沒有副作用或較不可能帶來副作用之狀況下提昇電子裝置的功能的多樣性。Another object of the present invention is to provide a method for performing hardware resource management in an electronic device and a corresponding electronic device for improving the functions of the electronic device without side effects or less likely to cause side effects. Sex.

本發明之至少一實施例提供一種用來於一電子裝置中進行硬體資源管理之方法。該方法可包含:利用該電子裝置中之一微處理器(microcontroller)執行一組程式碼之至少一部分,以控制該電子裝置,其中該電子裝置之多個運作包含一預定運作,該組程式碼包含用來控制該預定運作之一預定程式模組,該預定程式模組包含一局部程式(partial program),且該局部程式提供一變數存取服務予該預定程式模組;以及利用該微處理器執行該局部程式,以控制該電子裝置進行該預定運作。例如,利用該微處理器執行該局部程式以控制該電子裝置進行該預定運作可包含:將對應於一索引之資料從對應於該索引之一資料儲存區複製到一共享記憶體(shared memory)儲存區中之至少一共享變數(shared variable),其中該至少一共享變數是非陣列變數(non-array variable);操作(operate)該至少一共享變數中之該資料,以控制該電子裝置進行該預定運作之至少一部分,其中操作該至少一共享變數中之該資料包含存取該至少一共享變數中之該資料;以及將該至少一共享變數中之最新資料從該共享記憶體儲存區中之該至少一共享變數複製到對應於該索引之該資料儲存區。At least one embodiment of the present invention provides a method for hardware resource management in an electronic device. The method can include: using a microcontroller in the electronic device to execute at least a portion of a set of code to control the electronic device, wherein the plurality of operations of the electronic device include a predetermined operation, the set of code And a predetermined program module for controlling the predetermined operation, the predetermined program module includes a partial program, and the partial program provides a variable access service to the predetermined program module; and utilizing the micro processing The local program is executed to control the electronic device to perform the predetermined operation. For example, executing the local program by the microprocessor to control the electronic device to perform the predetermined operation may include: copying data corresponding to an index from a data storage area corresponding to the index to a shared memory. At least one shared variable in the storage area, wherein the at least one shared variable is a non-array variable; operating the data in the at least one shared variable to control the electronic device to perform the At least a portion of the predetermined operation, wherein operating the data in the at least one shared variable comprises accessing the data in the at least one shared variable; and updating the latest data in the at least one shared variable from the shared memory storage area The at least one shared variable is copied to the data storage area corresponding to the index.

本發明之至少一實施例提供一種電子裝置,其可包含:一記憶體,用來儲存該電子裝置之一組程式碼;以及一微處理器,耦接至該記憶體。該微處理器可用來執行該組程式碼之至少一部分,以控制該電子裝置,其中該電子裝置之多個運作包含一預定運作,該組程式碼包含用來控制該預定運作之一預定程式模組,該預定程式模組包含一局部程式,且該局部程式提供一變數存取服務予該預定程式模組。此外,該微處理器執行該局部程式,以控制該電子裝置進行該預定運作,其中執行該局部程式以控制該電子裝置進行該預定運作包含:將對應於一索引之資料從對應於該索引之一資料儲存區複製到一共享記憶體儲存區中之至少一共享變數,其中該至少一共享變數是非陣列變數,且該多個資料儲存區包含該共享記憶體儲存區以及對應於該索引之該資料儲存區;操作該至少一共享變數中之該資料,以控制該電子裝置進行該預定運作之至少一部分,其中操作該至少一共享變數中之該資料包含存取該至少一共享變數中之該資料;以及將該至少一共享變數中之最新資料從該共享記憶體儲存區中之該至少一共享變數複製到對應於該索引之該資料儲存區。At least one embodiment of the present invention provides an electronic device, which can include: a memory for storing a set of code of the electronic device; and a microprocessor coupled to the memory. The microprocessor can be configured to execute at least a portion of the set of code to control the electronic device, wherein the plurality of operations of the electronic device comprise a predetermined operation, the set of code comprising a predetermined programming mode for controlling the predetermined operation The program module includes a partial program, and the local program provides a variable access service to the predetermined program module. In addition, the microprocessor executes the local program to control the electronic device to perform the predetermined operation, wherein executing the partial program to control the electronic device to perform the predetermined operation comprises: selecting data corresponding to an index from the index corresponding to the index Copying a data storage area to at least one shared variable in a shared memory storage area, wherein the at least one shared variable is a non-array variable, and the plurality of data storage areas include the shared memory storage area and the corresponding to the index a data storage area; operating the data in the at least one shared variable to control the electronic device to perform at least a portion of the predetermined operation, wherein operating the data in the at least one shared variable comprises accessing the at least one shared variable Data; and copying the latest data of the at least one shared variable from the at least one shared variable in the shared memory storage area to the data storage area corresponding to the index.

本發明的好處之一是,藉由適當地進行硬體資源管理,本發明能針對變數存取運作進行妥善的控制,以有效地減少該電子裝置的至少一程式模組(諸如一或多個程式模組)中之每一程式模組之機器碼量,且可在硬體資源有限的狀況下大幅地提昇電子裝置的功能的多樣性。此外,依據本發明之相關實施例來實施並不會增加許多額外的成本。因此,相關技術的問題可被解決。相較於相關技術,本發明能在沒有副作用或較不可能帶來副作用之狀況下達到電子裝置之最佳化效能。One of the advantages of the present invention is that the present invention can properly control variable access operations by appropriately performing hardware resource management to effectively reduce at least one program module of the electronic device (such as one or more The program code of each program module in the program module can greatly improve the diversity of functions of the electronic device under the condition that the hardware resources are limited. Moreover, implementation in accordance with related embodiments of the present invention does not add many additional costs. Therefore, the problems of the related art can be solved. Compared with the related art, the present invention can achieve the optimization performance of the electronic device without side effects or less likely to cause side effects.

第1圖為依據本發明一實施例之一種電子裝置100的示意圖。電子裝置100可包含微處理器110與記憶體120。記憶體120可包含資料記憶體12,且可另包含程式記憶體124諸如指令記憶體(instruction memory),其中資料記憶體122可包含多個資料儲存區(未顯示於第1圖)。微處理器110與記憶體120可彼此耦接。例如資料記憶體122與程式記憶體124可分別透過資料匯流排與程式匯流排耦接至微處理器110,但本發明並不限於此。記憶體120可用來儲存資訊。例如資料記憶體122與程式記憶體124可分別儲存程式資料122D與程式碼124P。本實施例中,記憶體120(例如資料記憶體122與程式記憶體124)可為隨機存取記憶體,電子裝置100可另包含非揮發性記憶體(non-volatile memory, NV memory)130,且程式碼124P可從非揮發性記憶體130載入(load)至程式記憶體124,但本發明並不限於此。依據某些實施例,於電子裝置100中不需要設置非揮發性記憶體130,且程式碼124P可從電子裝置100以外載入至程式記憶體124。依據某些實施例,記憶體120可為任何類型的記憶體(例如非揮發性記憶體)。電子裝置100的例子可包含(但不限於):儲存裝置(例如隨身碟、硬式磁碟機、固態硬碟)、電視機、監視器(monitor)、穿戴裝置、多功能行動電話、個人電腦或任何其它類型的電子裝置。尤其是,電子裝置100可為多埠(Port)之電子裝置。FIG. 1 is a schematic diagram of an electronic device 100 according to an embodiment of the invention. The electronic device 100 can include a microprocessor 110 and a memory 120. The memory 120 can include a data memory 12, and can further include a program memory 124 such as an instruction memory, wherein the data memory 122 can include a plurality of data storage areas (not shown in FIG. 1). The microprocessor 110 and the memory 120 can be coupled to each other. For example, the data memory 122 and the program memory 124 can be coupled to the microprocessor 110 through the data bus and the program bus, respectively, but the invention is not limited thereto. The memory 120 can be used to store information. For example, the data memory 122 and the program memory 124 can store the program data 122D and the program code 124P, respectively. In this embodiment, the memory 120 (for example, the data memory 122 and the program memory 124) may be a random access memory, and the electronic device 100 may further include a non-volatile memory (NV memory) 130. The code 124P can be loaded from the non-volatile memory 130 to the program memory 124, but the invention is not limited thereto. According to some embodiments, the non-volatile memory 130 is not required to be disposed in the electronic device 100, and the code 124P can be loaded from the outside of the electronic device 100 to the program memory 124. According to some embodiments, the memory 120 can be any type of memory (eg, non-volatile memory). Examples of the electronic device 100 may include, but are not limited to, a storage device (such as a flash drive, a hard disk drive, a solid state drive), a television, a monitor, a wearable device, a multi-function mobile phone, a personal computer, or Any other type of electronic device. In particular, the electronic device 100 can be a multi-port electronic device.

微處理器110可執行程式碼124P,諸如電子裝置100之一組程式碼,以控制電子裝置100之多個運作,其可分別對應於電子裝置100的各種功能。該多個運作包含一預定運作,其可對應於上述各種功能中之某一功能。例如,該組程式碼可包含用來控制該預定運作之一預定程式模組,該預定程式模組可包含一局部程式,且該局部程式可提供一變數存取服務予該預定程式模組,以減少該預定程式模組存取陣列變數的機會(例如避免該預定程式模組存取任何陣列變數)。The microprocessor 110 can execute a program code 124P, such as a set of code of the electronic device 100, to control multiple operations of the electronic device 100, which can respectively correspond to various functions of the electronic device 100. The plurality of operations includes a predetermined operation that can correspond to one of the various functions described above. For example, the set of code may include a predetermined program module for controlling the predetermined operation, the predetermined program module may include a partial program, and the partial program may provide a variable access service to the predetermined program module. To reduce the chance that the predetermined program module accesses the array variables (for example, to prevent the predetermined program module from accessing any array variables).

為了便於理解,假設傳統方法使用陣列變數variable[x]來儲存某一個電子裝置之每一個埠的變數,其中x = 0代表埠0,x = 1代表埠1,依此類推。上述陣列變數variable[x]不只被使用一次,且這個電子裝置的各種操作中還有許多其它的陣列變數。若設計者嘗試賦予這個電子裝置很多功能,則各個陣列變數的存取運作(諸如讀取、寫入)會使這個電子裝置的韌體(firmware)程式之整體的機器碼量變得很大,而無法放入有限的記憶體儲存空間中。因此,設計者被迫捨棄一些功能。For ease of understanding, it is assumed that the conventional method uses the array variable variable[x] to store the variables of each 埠 of an electronic device, where x = 0 represents 埠0, x = 1 represents 埠1, and so on. The above array variable variable [x] is not only used once, and there are many other array variables in the various operations of this electronic device. If the designer attempts to give the electronic device a lot of functions, the access operations (such as reading and writing) of the various array variables will make the overall machine code of the firmware of the electronic device become large, and Cannot be placed in a limited memory storage space. Therefore, designers are forced to abandon some features.

相較於此,本發明可有效地解決問題。第2圖繪示第1圖所示電子裝置100於一實施例中之資料記憶體配置200。共享記憶體(shared memory)儲存區SHM與資料儲存區{PM(0), PM(1), …, PM(N - 1)}可位於第1圖所示資料記憶體122中,其中程式資料122D可包含資料記憶體配置200中之資料。本發明的方法可將所有的陣列變數全部改為一般變數,即非陣列變數(non-array variable),並可透過共享記憶體儲存區SHM進行資料交換,以操控到全部N個埠的變數。例如埠0至埠(N - 1)的變數可分別儲存於專屬的資料儲存區{PM(0), PM(1), …, PM(N - 1)}中,不會彼此受到影響。由於陣列變數variable[x]改為一般變數(諸如變數VARIABLE)可以減少微處理器抓取位址x的機器碼(machine code),所以當變數的數量愈多或變數被操作的次數愈多,則機器碼量降低的幅度愈大。In contrast, the present invention can effectively solve the problem. FIG. 2 is a diagram showing the data memory configuration 200 of the electronic device 100 shown in FIG. 1 in an embodiment. The shared memory storage area SHM and the data storage area {PM(0), PM(1), ..., PM(N - 1)} may be located in the data memory 122 shown in Fig. 1, wherein the program data The 122D can include data in the data memory configuration 200. The method of the present invention can change all array variables to general variables, that is, non-array variables, and can exchange data through the shared memory storage area SHM to manipulate all N 埠 variables. For example, the variables from 埠0 to 埠(N - 1) can be stored in the exclusive data storage areas {PM(0), PM(1), ..., PM(N - 1)}, respectively, and will not be affected by each other. Since the array variable variable[x] is changed to a general variable (such as the variable VARIABLE) to reduce the machine code of the microprocessor grabbing the address x, the more the number of variables or the more the number of variables being manipulated, Then the greater the amount of machine code reduction.

為了便於理解,埠0至埠(N - 1)的變數可作為資料儲存區{PM(0), PM(1), …, PM(N - 1)}中之資料的例子,但本發明並不限於此。依據某些實施例,任何其它類型的變數亦可作為資料儲存區{PM(0), PM(1), …, PM(N - 1)}中之資料的例子。For ease of understanding, the variables 埠0 to 埠(N - 1) can be used as examples of the data in the data storage areas {PM(0), PM(1), ..., PM(N - 1)}, but the present invention Not limited to this. According to some embodiments, any other type of variable may also be used as an example of data in the data storage area {PM(0), PM(1), ..., PM(N - 1)}.

第3圖為依據本發明一實施例之一種用來於一電子裝置中進行硬體資源管理之方法300的流程圖。方法300可作為上述本發明的方法之一例,且可應用於第1圖所示電子裝置100。FIG. 3 is a flow chart of a method 300 for performing hardware resource management in an electronic device in accordance with an embodiment of the invention. The method 300 can be applied as an example of the method of the present invention described above, and can be applied to the electronic device 100 shown in FIG.

於步驟310中,電子裝置100將程式碼124P(諸如上述該組程式碼)載入到程式記憶體124,以容許微處理器110執行程式碼124P。例如該組程式碼可以不包含任何陣列變數,但本發明並不限於此。In step 310, the electronic device 100 loads the program code 124P (such as the above-mentioned set of code) into the program memory 124 to allow the microprocessor 110 to execute the program code 124P. For example, the set of code may not contain any array variables, but the invention is not limited thereto.

於步驟320中,微處理器110執行程式碼124P之至少一部分,以控制電子裝置100。In step 320, the microprocessor 110 executes at least a portion of the code 124P to control the electronic device 100.

於步驟330中,微處理器110執行該局部程式,以控制電子裝置100進行該預定運作。例如該局部程式可為一變數存取服務迴圈,且微處理器110可依據索引X執行該變數存取服務迴圈,以於該變數存取服務迴圈中隨著索引X之變化控制電子裝置100進行該預定運作,但本發明並不限於此。In step 330, the microprocessor 110 executes the partial program to control the electronic device 100 to perform the predetermined operation. For example, the local program can be a variable access service loop, and the microprocessor 110 can perform the variable access service loop according to the index X, so as to control the electronic with the change of the index X in the variable access service loop. The device 100 performs the predetermined operation, but the present invention is not limited thereto.

依據本實施例,微處理器110可依據下列步驟a至g控制電子裝置100進行該預定運作: a. 令X = 0; b. 若X < N,則前往步驟c,否則,前往步驟g; c. 複製對應於索引X之資料儲存區PM(X)至共享記憶體儲存區SHM,例如:將對應於索引X之資料從對應於索引X之資料儲存區PM(X)複製到共享記憶體儲存區SHM中之至少一共享變數(例如一共享變數VARIABLE、或多個共享變數{variable1, variable2, variable3, …}),其中該至少一共享變數是非陣列變數,且該多個資料儲存區包含共享記憶體儲存區SHM以及對應於索引X之資料儲存區PM(X); d. 操作(operate)位於共享記憶體儲存區SHM中之一般變數,例如:操作該至少一共享變數(例如共享變數VARIABLE、或共享變數{variable1, variable2, variable3, …})中之該資料,以控制電子裝置100進行該預定運作之至少一部分,其中操作該至少一共享變數中之該資料可包含存取該至少一共享變數中之該資料; e. 複製共享記憶體儲存區SHM至對應於索引X之資料儲存區PM(X),例如:將該至少一共享變數中之最新資料從共享記憶體儲存區SHM中之該至少一共享變數(例如共享變數VARIABLE、或共享變數{variable1, variable2, variable3, …})複製到對應於索引X之資料儲存區PM(X); f. 令X = X + 1且前往步驟b; g. 結束; 其中步驟330之運作可包含步驟a至g之至少一部分(例如一部分或全部),尤其是步驟c至e,且步驟b至f所形成的迴圈可作為該變數存取服務迴圈之一例。According to this embodiment, the microprocessor 110 can control the electronic device 100 to perform the predetermined operation according to the following steps a to g: a. Let X = 0; b. If X < N, go to step c, otherwise, go to step g; c. Copy the data storage area PM(X) corresponding to the index X to the shared memory storage area SHM, for example, copy the data corresponding to the index X from the data storage area PM(X) corresponding to the index X to the shared memory At least one shared variable (eg, a shared variable VARIABLE, or a plurality of shared variables {variable1, variable2, variable3, ...}) in the storage area SHM, wherein the at least one shared variable is a non-array variable, and the plurality of data storage areas include a shared memory storage area SHM and a data storage area PM(X) corresponding to the index X; d. operating a general variable located in the shared memory storage area SHM, for example, operating the at least one shared variable (eg, sharing variables) The data in the VARIABLE, or the shared variable {variable1, variable2, variable3, ...}), to control the electronic device 100 to perform at least a portion of the predetermined operation, wherein the at least one shared variable is operated The material may include accessing the data in the at least one shared variable; e. copying the shared memory storage area SHM to the data storage area PM(X) corresponding to the index X, for example, updating the latest data in the at least one shared variable Copying the at least one shared variable (eg, shared variable VARIABLE, or shared variable {variable1, variable2, variable3, ...}) from the shared memory storage area SHM to the data storage area PM(X) corresponding to the index X; f. Let X = X + 1 and proceed to step b; g. End; wherein the operation of step 330 may comprise at least a portion (eg, a portion or all) of steps a through g, particularly steps c through e, and steps b through f are formed The loop can be used as an example of the variable access service loop.

基於本發明的方法諸如方法300,透過該變數存取服務,該組程式碼中之至少一部分程式碼之機器碼量已變小,使電子裝置100之一記憶體(例如程式記憶體124、或任何其它類型的記憶體)的儲存容量足以儲存該組程式碼(亦即,該組程式碼已經變小且小到足以被放進這個記憶體)。尤其是,透過該變數存取服務,該預定程式模組中之所有需要陣列變數之處已分別被取代為關於該至少一共享變數(例如共享變數VARIABLE、或共享變數{variable1, variable2, variable3, …})之多個存取運作,以減少該預定程式模組於程式記憶體124中之機器碼量(其代表該預定程式模組於程式記憶體124中之大小)。例如:透過該變數存取服務,當該組程式碼被載入到程式記憶體124時,該組程式碼中之該預定程式模組已變小(例如已被最小化),但本發明不限於此。假設電子裝置100之該多個運作分別對應於電子裝置100之多個功能,且該預定運作對應於該多個功能中之一預定功能。例如,透過該變數存取服務,該組程式碼當中對應於該預定功能之程式碼已變小(例如已被最小化),以於程式記憶體124中保留儲存空間給該組程式碼當中對應於其它功能之程式碼。The method according to the present invention, such as method 300, by means of the variable access service, the amount of machine code of at least a portion of the code of the set of codes has become smaller, such that a memory of the electronic device 100 (eg, the program memory 124, or The storage capacity of any other type of memory is sufficient to store the set of code (i.e., the set of code has become smaller and smaller enough to be placed into the memory). In particular, through the variable access service, all of the required array variables in the predetermined program module have been replaced with respect to the at least one shared variable (eg, shared variable VARIABLE, or shared variable {variable1, variable2, variable3, respectively). A plurality of access operations are performed to reduce the amount of machine code in the program memory 124 of the predetermined program module (which represents the size of the predetermined program module in the program memory 124). For example, through the variable access service, when the set of code is loaded into the program memory 124, the predetermined program module in the set of codes has become smaller (for example, has been minimized), but the present invention does not Limited to this. It is assumed that the plurality of operations of the electronic device 100 respectively correspond to a plurality of functions of the electronic device 100, and the predetermined operation corresponds to one of the plurality of functions. For example, through the variable access service, the code corresponding to the predetermined function in the set of code codes has become smaller (for example, has been minimized), so that the storage space in the program memory 124 is reserved for the corresponding code in the set of codes. The code for other functions.

依據某些實施例,步驟d之運作可予以變化。例如,操作該至少一共享變數中之該資料可另包含:將至少一運算子施加於(apply to)該至少一共享變數(例如共享變數VARIABLE、或共享變數{variable1, variable2, variable3, …})中之該資料,以產生該至少一共享變數中之該最新資料。According to certain embodiments, the operation of step d can be varied. For example, operating the data in the at least one shared variable may further comprise: applying at least one operator to the at least one shared variable (eg, a shared variable VARIABLE, or a shared variable {variable1, variable2, variable3, ...} The information in the ) to generate the latest information in the at least one shared variable.

舉例來說,符號{OP_A, OP_B, OP_C, OP_D, …}可代表運算子,其例子可包含(但不限於):讀、寫、各種運算(諸如加、減、乘、除、模(mod)運算…等)及各種涉及讀/寫的操作。上述傳統方法中可能操作各種陣列變數諸如陣列變數{variable1[x], variable2[x], variable3[x], …},如下列虛擬程式碼所示:(以C語言為例) for(x=0; x<N; x++) // N is Number of Port { OP_A variable1[x]; // 操作陣列變數variable1[x] OP_B variable2[x]; // 操作陣列變數variable2[x] OP_C variable1[x]; // 操作陣列變數variable1[x] OP_D variable3[x]; // 操作陣列變數variable3[x] }For example, the symbols {OP_A, OP_B, OP_C, OP_D, ...} may represent operators, examples of which may include (but are not limited to): read, write, various operations (such as addition, subtraction, multiplication, division, modulo (mod) ) Operations...etc.) and various operations involving reading/writing. The above conventional methods may operate various array variables such as array variables {variable1[x], variable2[x], variable3[x], ...}, as shown in the following virtual code: (in C language as an example) for(x= 0; x<N; x++) // N is Number of Port { OP_A variable1[x]; // Operate array variable variable1[x] OP_B variable2[x]; // Operate array variable variable2[x] OP_C variable1[x ]; // Operate array variable variable1[x] OP_D variable3[x]; // Operate array variable variable3[x] }

相較於此,本發明的方法可透過該變數存取服務來操作共享變數{variable1, variable2, variable3, …}(其為非陣列變數),如下列虛擬程式碼所示:(以C語言為例) for(X=0; X<N; X++) // N可代表埠的數量 { memcpy(shared_memory, port_memory[X], memory_size); // 複製對應於索引X之資料儲存區至共享記憶體儲存區 OP_A variable1; // 操作共享記憶體儲存區SHM中之共享變數variable1 OP_B variable2; // 操作共享記憶體儲存區SHM中之共享變數variable2 OP_C variable1; // 操作共享記憶體儲存區SHM中之共享變數variable1 OP_D variable3; // 操作共享記憶體儲存區SHM中之共享變數variable3 memcpy(port_memory[X], shared_memory, count); // 複製共享記憶體儲存區至對應於索引X之資料儲存區 } 其中指標(pointer)shared_memory與port_memory[X]可分別指向共享記憶體儲存區SHM與對應於索引X之資料儲存區PM(X),數值memory_size可代表資料儲存區PM(X)之整個區域的大小(例如資料儲存區PM(X)的大小等同於共享記憶體儲存區SHM的大小),且上列虛擬程式碼中之迴圈可作為該變數存取服務迴圈之另一例。舉例來說,該預定程式模組可為一函式、且該函式可包含這個迴圈,但本發明並不限於此。 表1 <TABLE border="1" borderColor="#000000" width="85%"><TBODY><tr><td> 記憶體需求 </td><td> 傳統方法 </td><td> 本發明的方法 </td></tr><tr><td> 資料記憶體的需求 </td><td> Q * M * N </td><td> Q * M * (N + 1) </td></tr><tr><td> 程式記憶體的需求 </td><td> M * K * (T + R) </td><td> 2 * S + M * K * R </td></tr></TBODY></TABLE>In contrast, the method of the present invention can operate the shared variable {variable1, variable2, variable3, ...} (which is a non-array variable) through the variable access service, as shown in the following virtual code: (in C language Example) for(X=0; X<N; X++) // N can represent the number of { { memcpy(shared_memory, port_memory[X], memory_size); // copy the data storage area corresponding to index X to shared memory Storage area OP_A variable1; // Operation shared variable storage area SHM shared variable variable1 OP_B variable2; // Operation shared memory storage area SHM shared variable variable2 OP_C variable1; // Operation shared memory storage area SHM Shared variable variable1 OP_D variable3; // Operation shared variable in shared memory storage area SHM variable3 memcpy(port_memory[X], shared_memory, count); // Copy shared memory storage area to data storage area corresponding to index X} The pointers shared_memory and port_memory[X] can point to the shared memory storage area SHM and the corresponding index X, respectively. The material storage area PM(X), the value memory_size may represent the size of the entire area of the data storage area PM(X) (for example, the size of the data storage area PM(X) is equal to the size of the shared memory storage area SHM), and the above The loop in the virtual code can be used as another example of the variable access service loop. For example, the predetermined program module can be a function, and the function can include the loop, but the invention is not limited thereto. Table 1  <TABLE border="1" borderColor="#000000" width="85%"><TBODY><tr><td> Memory Requirements</td><td> Traditional Method</td><td> The present invention Method</td></tr><tr><td> Data Memory Requirements</td><td> Q * M * N </td><td> Q * M * (N + 1) < /td></tr><tr><td> Requirements for program memory</td><td> M * K * (T + R) </td><td> 2 * S + M * K * R </td></tr></TBODY></TABLE>

表1是傳統方法與本發明的方法之間的比較表。關於資料記憶體的需求,Q是變數的平均大小,M是變數的數量,且N是埠的數量,其中(Q * M)可稱為總位元組數(total byte count);例如:至少一變數中之每一變數可占用一個位元組、及/或至少一變數中之每一變數可占用多個位元組。由於傳統方法使用陣列變數(例如陣列變數{variable1[x], variable2[x], variable3[x], …}),故所需資料記憶體的儲存空間為所有陣列變數的儲存空間的總和,即 (Q * M * N) 位元組。另外,由於本發明的方法使用一般變數,故所需資料記憶體的儲存空間為所有一般變數的儲存空間的總和(即總位元組數(Q * M))再乘以(N + 1),即 (Q * M * (N + 1)) 位元組,其中1是指需額外增加一份一般變數(其儲存於共享記憶體儲存區SHM)。例如資料儲存區PM(X)與共享記憶體儲存區SHM中之每一者的大小可等於總位元組數(Q * M)。Table 1 is a comparison table between the conventional method and the method of the present invention. Regarding the demand for data memory, Q is the average size of the variable, M is the number of variables, and N is the number of ,, where (Q * M) can be called the total byte count; for example: at least Each of the variables may occupy one byte, and/or each of the at least one variable may occupy a plurality of bytes. Since the conventional method uses array variables (for example, array variables {variable1[x], variable2[x], variable3[x], ...}), the storage space of the required data memory is the sum of the storage spaces of all the array variables, that is, (Q * M * N) Bytes. In addition, since the method of the present invention uses general variables, the storage space of the required data memory is the sum of the storage spaces of all the general variables (ie, the total number of bytes (Q * M)) and multiplied by (N + 1). That is, (Q * M * (N + 1)) bytes, where 1 means an additional general variable (which is stored in the shared memory storage area SHM). For example, the size of each of the data storage area PM(X) and the shared memory storage area SHM may be equal to the total number of bytes (Q*M).

關於程式記憶體的需求,M是變數的數量,K是變數被讀取/寫入的平均次數,T是微處理器存取時需額外處理陣列索引的機器碼量(以「8051」型微處理器為例,當採用某一個編譯器(compiler)及某一個最佳化等級(optimization level)時,讀取陣列變數時比讀取一般變數時多出10位元組(byte),寫入陣列變數時比寫入一般變數時多出12位元組,但本發明並不限於此),R是微處理器操作(例如數學運算、邏輯運算、存取…等)變數的機器碼量,S是函式memcpy( )的機器碼量。本發明的方法比傳統方法雖然多出對應於 (2 * S) 的機器碼量,但節省了對應於 (M * K * T) 的機器碼量,其通常遠大於對應於 (2 * S) 的機器碼量。因此,本發明的方法可大幅地減少至少一程式模組(諸如一或多個程式模組)的機器碼量,且可在硬體資源相當有限的狀況下賦予電子裝置100很多功能,以提昇電子裝置100的功能的多樣性。Regarding the requirements of the program memory, M is the number of variables, K is the average number of times the variables are read/written, and T is the amount of machine code that needs to be additionally processed by the array when the microprocessor accesses ("8051" type micro For example, when using a compiler and an optimization level, when reading array variables, it is 10 bytes more than when reading general variables. The array variable is 12 bits more than when the general variable is written, but the present invention is not limited thereto, and R is the machine code amount of the microprocessor operation (for example, mathematical operation, logical operation, access, etc.) variable. S is the machine code of the function memcpy( ). The method of the present invention saves the machine code amount corresponding to (M * K * T), although it is more than the machine code amount corresponding to (2 * S), which is usually much larger than the corresponding (2 * S). The amount of machine code. Therefore, the method of the present invention can greatly reduce the machine code size of at least one program module (such as one or more program modules), and can give the electronic device 100 a lot of functions under the condition that the hardware resources are rather limited. The diversity of functions of the electronic device 100.

依據某些實施例,程式記憶體124諸如指令記憶體可以是揮發性記憶體(例如靜態隨機存取記憶體(Static Random Access Memory;可簡稱為SRAM)、動態隨機存取記憶體(Dynamic Random Access Memory;可簡稱為DRAM)...等)、或非揮發性記憶體(例如遮罩唯讀記憶體(Mask Read-Only Memory;可簡稱為Mask ROM)、快閃記憶體(Flash memory;可簡稱為Flash)、電子可抹除可編程唯讀記憶體(Electrically-Erasable Programmable Read-Only Memory;可簡稱為EEPROM)…等)。依據某些實施例,資料記憶體122可以是揮發性記憶體(例如SRAM、DRAM...等)、或非揮發性記憶體(例如Flash、EEPROM…等)。依據某些實施例,程式記憶體124與資料記憶體122可以共用同一個實體記憶體(Physical Memory)、或分別使用各自的實體記憶體。例如:若要共用,不可使用Mask ROM。依據某些實施例,機器碼可以只被製作在積體電路(IC)內的Mask ROM裡、或者可以只被燒錄在Flash或EEPROM裡、或者可以只被載入到隨機存取記憶體裡,但本發明不限於此。例如:機器碼可被製作在積體電路內的Mask ROM裡、被燒錄在Flash或EEPROM裡、及/或被載入到隨機存取記憶體。依據某些實施例,降低機器碼量的好處可包含:能在程式記憶體124之原來的儲存空間內增加分別對應於更多功能之程式以增加電子裝置100的附加價值、及/或減小程式記憶體124的大小以降低成本。依據某些實施例,不同的編譯器或不同等級的碼最佳化(Code Optimization)的相關設定可影響機器碼量。According to some embodiments, the program memory 124 such as the instruction memory may be a volatile memory (for example, a static random access memory (SRAM), a dynamic random access memory (Dynamic Random Access Memory). Memory; can be abbreviated as DRAM), or non-volatile memory (such as Mask Read-Only Memory (Mask ROM), Flash Memory; Referred to as Flash), Electrically-Erasable Programmable Read-Only Memory (abbreviated as EEPROM), etc.). According to some embodiments, the data memory 122 may be a volatile memory (eg, SRAM, DRAM, etc.), or a non-volatile memory (eg, Flash, EEPROM, etc.). According to some embodiments, the program memory 124 and the data memory 122 may share the same physical memory or use respective physical memory. For example, if you want to share, you can't use Mask ROM. According to some embodiments, the machine code may be fabricated only in the Mask ROM within the integrated circuit (IC), or may be only burned in the Flash or EEPROM, or may only be loaded into the random access memory. However, the invention is not limited thereto. For example, the machine code can be created in a Mask ROM in an integrated circuit, burned in Flash or EEPROM, and/or loaded into random access memory. According to some embodiments, the benefit of reducing the amount of machine code may include adding a program corresponding to more functions in the original storage space of the program memory 124 to increase the added value of the electronic device 100, and/or reducing The size of the program memory 124 is reduced to reduce cost. Depending on certain embodiments, different compilers or different levels of code optimization related settings may affect the machine code size.

另外,傳統方法除了使用陣列(array)變數之外,也有可能使用指標(pointer)變數、結構(struct)變數、聯合(union)變數、混合上述變數…等間接存取(需額外處理陣列/指標索引(array/pointer index)或結構/聯合成員(struct/union member))數值的變數。相較於此,本發明可透過該變數存取服務來減少機器碼量。例如:於某些實施例中,一般變數可泛指不需處理陣列/指標索引或結構/聯合成員等額外處理的變數。依據某些實施例,在對應於索引X之資料儲存區PM(X)中,不同變數所佔的大小可能不同,例如:某(些)變數可佔1個位元組,某(些)變數可佔2個位元組,某(些)變數可佔4個位元組、及/或某(些)變數可佔超過4個位元組。In addition, in addition to the use of array variables, the conventional method may also use indirect access such as pointer variables, struct variables, union variables, and mixing of the above variables (additional processing of arrays/indicators is required). The index (array/pointer index) or structure/joint member (struct/union member) variable of the value. In contrast, the present invention can reduce the amount of machine code through the variable access service. For example, in some embodiments, a generic variable can generally refer to a variable that does not require additional processing such as array/index indexing or structure/joining members. According to some embodiments, in the data storage area PM(X) corresponding to the index X, the size of the different variables may be different, for example, the variable(s) may occupy 1 byte, and some (some) variables Can occupy 2 bytes, some (some) variables can occupy 4 bytes, and / or some (some) variables can account for more than 4 bytes.

本發明的方法除了能採用該變數存取服務迴圈來實現上述之該局部程式以外,也可以用非迴圈的方式來實現該局部程式。例如,本發明的方法可透過該變數存取服務來操作共享變數{variable1, variable2, variable3, …},如下列虛擬程式碼所示:(以C語言為例) void func(void) { OP_A variable1; // 操作共享記憶體儲存區SHM中之共享變數variable1 OP_B variable2; // 操作共享記憶體儲存區SHM中之共享變數variable2 OP_C variable1; // 操作共享記憶體儲存區SHM中之共享變數variable1 OP_D variable3; // 操作共享記憶體儲存區SHM中之共享變數variable3 } // 埠0 memcpy(shared_memory, port_memory[0], memory_size); // 複製對應於索引X(X = 0)之資料儲存區至共享記憶體儲存區 func(); memcpy(port_memory[0], shared_memory, memory_size); // 複製共享記憶體儲存區至對應於索引X(X = 0)之資料儲存區 // 埠1 memcpy(shared_memory, port_memory[1], memory_size); // 複製對應於索引X(X = 1)之資料儲存區至共享記憶體儲存區 func(); memcpy(port_memory[1], shared_memory, memory_size); // 複製共享記憶體儲存區至對應於索引X(X = 1)之資料儲存區 // ……. // 埠(N - 1) memcpy(shared_memory, port_memory[N-1], memory_size); // 複製對應於索引X(X = N - 1)之資料儲存區至共享記憶體儲存區 func(); memcpy(port_memory[N-1], shared_memory, memory_size); // 複製共享記憶體儲存區至對應於索引X(X = N - 1)之資料儲存區 其中func( )可代表函式。上述之該變數存取服務迴圈之運作已被打散成引用函式func( )的N組指令,使微處理器110如同依據索引X執行該變數存取服務迴圈,但本發明不限於此。上列(引用函式func( )的)該N組指令可模擬該變數存取服務迴圈,但本發明不限於此。In addition to the variable access service loop to implement the above-mentioned partial program, the method of the present invention can also implement the partial program in a non-loop manner. For example, the method of the present invention can operate the shared variable {variable1, variable2, variable3, ...} through the variable access service, as shown in the following virtual code: (in the C language as an example) void func(void) { OP_A variable1 ; // Operation shared variable storage area SHM shared variable variable1 OP_B variable2; // Operation shared memory storage area SHM shared variable variable2 OP_C variable1; // Operation shared memory storage area SHM shared variable variable1 OP_D Variable3; // Operation shared variable storage area SHM shared variable variable3 } // 埠0 memcpy(shared_memory, port_memory[0], memory_size); // copy the data storage area corresponding to index X (X = 0) to Shared memory storage area func(); memcpy(port_memory[0], shared_memory, memory_size); // Copy shared memory storage area to data storage area corresponding to index X (X = 0) // 埠1 memcpy(shared_memory , port_memory[1], memory_size); // copy the data storage area corresponding to the index X (X = 1) to the shared memory storage area func(); memcpy(port_memory[1 ], shared_memory, memory_size); // Copy the shared memory storage area to the data storage area corresponding to the index X (X = 1) //....... // 埠(N - 1) memcpy(shared_memory, port_memory[N- 1], memory_size); // Copy the data storage area corresponding to the index X (X = N - 1) to the shared memory storage area func(); memcpy(port_memory[N-1], shared_memory, memory_size); Copy the shared memory storage area to the data storage area corresponding to the index X (X = N - 1) where func( ) can represent the function. The operation of the variable access service loop described above has been broken up into N sets of instructions of the reference function func( ), so that the microprocessor 110 performs the variable access service loop as in the index X, but the invention is not limited thereto. this. The N sets of instructions (of the reference function func( )) can simulate the variable access service loop, but the invention is not limited thereto.

本發明的方法可降低韌體程式之整體的機器碼量,但本發明並不限於此。依據某些實施例,本發明的方法可降低任何其它類型的程式(諸如應用程式(Application)或驅動程式(Driver)的程式碼)之整體的機器碼量。 以上所述僅為本發明之較佳實施例,凡依本發明申請專利範圍所做之均等變化與修飾,皆應屬本發明之涵蓋範圍。The method of the present invention can reduce the overall machine code amount of the firmware program, but the present invention is not limited thereto. In accordance with certain embodiments, the method of the present invention can reduce the overall machine code size of any other type of program, such as an application or driver code. The above are only the preferred embodiments of the present invention, and all changes and modifications made to the scope of the present invention should be within the scope of the present invention.

100‧‧‧電子裝置100‧‧‧Electronic devices

110‧‧‧微處理器110‧‧‧Microprocessor

120‧‧‧記憶體120‧‧‧ memory

122‧‧‧資料記憶體122‧‧‧Data Memory

122D‧‧‧程式資料122D‧‧‧Program data

124‧‧‧程式記憶體124‧‧‧Program memory

124P‧‧‧程式碼124P‧‧‧ Code

130‧‧‧非揮發性記憶體130‧‧‧Non-volatile memory

200‧‧‧記憶體配置200‧‧‧ memory configuration

300‧‧‧方法300‧‧‧ method

310‧‧‧將程式碼載入到程式記憶體之步驟310‧‧‧Steps to load the code into the program memory

320‧‧‧執行程式碼之至少一部分以控制電子裝置之步驟320‧‧‧ Steps to execute at least part of the code to control the electronic device

330‧‧‧執行局部程式以控制電子裝置進行預定運作之步驟330‧‧‧Steps to execute a partial program to control the electronic device for scheduled operation

PM(0), PM(1), …, PM(N - 1)‧‧‧資料儲存區PM(0), PM(1), ..., PM(N - 1)‧‧‧ data storage area

SHM‧‧‧共享記憶體儲存區SHM‧‧‧ shared memory storage area

第1圖為依據本發明一實施例之一種電子裝置的示意圖。 第2圖繪示第1圖所示電子裝置於一實施例中之資料記憶體配置。 第3圖為依據本發明一實施例之一種用來於一電子裝置中進行硬體資源管理之方法的流程圖。FIG. 1 is a schematic diagram of an electronic device according to an embodiment of the invention. FIG. 2 is a diagram showing the data memory configuration of the electronic device shown in FIG. 1 in an embodiment. FIG. 3 is a flow chart of a method for hardware resource management in an electronic device according to an embodiment of the invention.

Claims (19)

一種用來於一電子裝置中進行硬體資源管理之方法,該方法包含有:利用該電子裝置中之一微處理器(microcontroller)執行一組程式碼之至少一部分,以控制該電子裝置,其中該電子裝置之多個運作包含一預定運作,該組程式碼包含用來控制該預定運作之一預定程式模組,該預定程式模組包含一局部程式(partial program),且該局部程式提供一變數存取服務予該預定程式模組;以及利用該微處理器執行該局部程式,以控制該電子裝置進行該預定運作,其中執行該局部程式以控制該電子裝置進行該預定運作包含:將對應於一索引之資料從對應於該索引之一資料儲存區複製到一共享記憶體(shared memory)儲存區中之多個共享變數(shared variable),其中該多個共享變數是非陣列變數(non-array variable);分別操作(operate)該多個共享變數中之該資料,以控制該電子裝置進行該預定運作之至少一部分,其中分別操作該多個共享變數中之該資料包含分別存取該多個共享變數中之該資料;以及將該多個共享變數中之最新資料從該共享記憶體儲存區中之該多個共享變數複製到對應於該索引之該資料儲存區。 A method for hardware resource management in an electronic device, the method comprising: using a microprocessor in the electronic device to execute at least a portion of a set of code to control the electronic device, wherein The plurality of operations of the electronic device include a predetermined operation, the set of code includes a predetermined program module for controlling the predetermined operation, the predetermined program module includes a partial program, and the partial program provides a And the variable accessing service to the predetermined program module; and executing the partial program by the microprocessor to control the electronic device to perform the predetermined operation, wherein executing the partial program to control the electronic device to perform the predetermined operation comprises: corresponding The data of an index is copied from a data storage area corresponding to one index to a plurality of shared variables in a shared memory storage area, wherein the plurality of shared variables are non-array variables (non- Array variable); operating the data in the plurality of shared variables respectively to control the electronic device to perform the pre- At least a portion of the operation, wherein respectively operating the data of the plurality of shared variables comprises separately accessing the data of the plurality of shared variables; and reading the latest data of the plurality of shared variables from the shared memory storage area The plurality of shared variables are copied to the data storage area corresponding to the index. 如申請專利範圍第1項所述之方法,其中分別操作該多個共享變數中之該資料另包含:分別將多個運算子施加於(apply to)該多個共享變數中之該資料,以產生該多個共享變數中之該最新資料。 The method of claim 1, wherein separately operating the data of the plurality of shared variables further comprises: applying a plurality of operators to the plurality of shared variables, respectively, to The latest data in the plurality of shared variables is generated. 一種用來於一電子裝置中進行硬體資源管理之方法,該方法包含有:利用該電子裝置中之一微處理器(microcontroller)執行一組程式碼之至少一部分,以控制該電子裝置,其中該電子裝置之多個運作包含一預定運作,該組程式碼包含用來控制該預定運作之一預定程式模組,該預定程式模組包含一局部程式(partial program),且該局部程式提供一變數存取服務予該預定程式模組;以及利用該微處理器執行該局部程式,以控制該電子裝置進行該預定運作,其中執行該局部程式以控制該電子裝置進行該預定運作包含:將對應於一索引之資料從對應於該索引之一資料儲存區複製到一共享記憶體(shared memory)儲存區中之至少一共享變數(shared variable),其中該至少一共享變數是非陣列變數(non-array variable);操作(operate)該至少一共享變數中之該資料,以控制該電子裝置進行該預定運作之至少一部分,其中操作該至少一共享變數中之該資料包含存取該至少一共享變數中之該資料;以及將該至少一共享變數中之最新資料從該共享記憶體儲存區中之該至少一共享變數複製到對應於該索引之該資料儲存區;其中該局部程式提供該變數存取服務予該預定程式模組,以減少該預定程式模組存取(access)陣列變數(array variable)的機會。 A method for hardware resource management in an electronic device, the method comprising: using a microprocessor in the electronic device to execute at least a portion of a set of code to control the electronic device, wherein The plurality of operations of the electronic device include a predetermined operation, the set of code includes a predetermined program module for controlling the predetermined operation, the predetermined program module includes a partial program, and the partial program provides a And the variable accessing service to the predetermined program module; and executing the partial program by the microprocessor to control the electronic device to perform the predetermined operation, wherein executing the partial program to control the electronic device to perform the predetermined operation comprises: corresponding The data of an index is copied from a data storage area corresponding to the index to at least one shared variable in a shared memory storage area, wherein the at least one shared variable is a non-array variable (non- Array variable); operating the data in the at least one shared variable to control the electronic device to perform the At least a portion of the operation, wherein operating the data in the at least one shared variable comprises accessing the material in the at least one shared variable; and updating the latest data in the at least one shared variable from the shared memory storage area Copying the at least one shared variable to the data storage area corresponding to the index; wherein the local program provides the variable access service to the predetermined program module to reduce the predetermined program module access array variable (array) Variable) opportunity. 如申請專利範圍第3項所述之方法,其中操作該至少一共享變數中之該資料另包含:將至少一運算子施加於(apply to)該至少一共享變數中之該資料,以產生該至少一共享變數中之該最新資料。 The method of claim 3, wherein the operating the data in the at least one shared variable further comprises: applying at least one operator to the data in the at least one shared variable to generate the At least one of the latest data in the shared variable. 一種用來於一電子裝置中進行硬體資源管理之方法,該方法包含有:利用該電子裝置中之一微處理器(microcontroller)執行一組程式碼之至少一部分,以控制該電子裝置,其中該電子裝置之多個運作包含一預定運作,該組程式碼包含用來控制該預定運作之一預定程式模組,該預定程式模組包含一局部程式(partial program),且該局部程式提供一變數存取服務予該預定程式模組;以及利用該微處理器執行該局部程式,以控制該電子裝置進行該預定運作,其中執行該局部程式以控制該電子裝置進行該預定運作包含:將對應於一索引之資料從對應於該索引之一資料儲存區複製到一共享記憶體(shared memory)儲存區中之至少一共享變數(shared variable),其中該至少一共享變數是非陣列變數(non-array variable);操作(operate)該至少一共享變數中之該資料,以控制該電子裝置進行該預定運作之至少一部分,其中操作該至少一共享變數中之該資料包含存取該至少一共享變數中之該資料;以及將該至少一共享變數中之最新資料從該共享記憶體儲存區中之該至少一共享變數複製到對應於該索引之該資料儲存區;其中透過該變數存取服務,該組程式碼中之至少一部分程式碼之機器碼量(machine code size)已變小,使該電子裝置之一記憶體的儲存容量足以儲存該組程式碼。 A method for hardware resource management in an electronic device, the method comprising: using a microprocessor in the electronic device to execute at least a portion of a set of code to control the electronic device, wherein The plurality of operations of the electronic device include a predetermined operation, the set of code includes a predetermined program module for controlling the predetermined operation, the predetermined program module includes a partial program, and the partial program provides a And the variable accessing service to the predetermined program module; and executing the partial program by the microprocessor to control the electronic device to perform the predetermined operation, wherein executing the partial program to control the electronic device to perform the predetermined operation comprises: corresponding The data of an index is copied from a data storage area corresponding to the index to at least one shared variable in a shared memory storage area, wherein the at least one shared variable is a non-array variable (non- Array variable); operating the data in the at least one shared variable to control the electronic device to perform the At least a portion of the operation, wherein operating the data in the at least one shared variable comprises accessing the material in the at least one shared variable; and updating the latest data in the at least one shared variable from the shared memory storage area Copying the at least one shared variable to the data storage area corresponding to the index; wherein, by using the variable access service, a machine code size of at least a part of the code of the set of codes has become smaller, so that One of the storage devices of the electronic device has a storage capacity sufficient to store the set of code. 如申請專利範圍第5項所述之方法,其中操作該至少一共享變數中之該資料另包含: 將至少一運算子施加於(apply to)該至少一共享變數中之該資料,以產生該至少一共享變數中之該最新資料。 The method of claim 5, wherein the operating the data in the at least one shared variable further comprises: Applying at least one operator to the data in the at least one shared variable to generate the latest data in the at least one shared variable. 一種用來於一電子裝置中進行硬體資源管理之方法,該方法包含有:利用該電子裝置中之一微處理器(microcontroller)執行一組程式碼之至少一部分,以控制該電子裝置,其中該電子裝置之多個運作包含一預定運作,該組程式碼包含用來控制該預定運作之一預定程式模組,該預定程式模組包含一局部程式(partial program),且該局部程式提供一變數存取服務予該預定程式模組;以及利用該微處理器執行該局部程式,以控制該電子裝置進行該預定運作,其中執行該局部程式以控制該電子裝置進行該預定運作包含:將對應於一索引之資料從對應於該索引之一資料儲存區複製到一共享記憶體(shared memory)儲存區中之至少一共享變數(shared variable),其中該至少一共享變數是非陣列變數(non-array variable);操作(operate)該至少一共享變數中之該資料,以控制該電子裝置進行該預定運作之至少一部分,其中操作該至少一共享變數中之該資料包含存取該至少一共享變數中之該資料;以及將該至少一共享變數中之最新資料從該共享記憶體儲存區中之該至少一共享變數複製到對應於該索引之該資料儲存區;其中,透過該變數存取服務,該預定程式模組中之所有需要陣列變數之處已分別被取代為關於該至少一共享變數之多個存取運作,以減少該預定程式模組於該電子裝置之一記憶體中之機器碼量(machine code size),其中該機器碼量代表該預定程式模組於該記憶體中之大小。 A method for hardware resource management in an electronic device, the method comprising: using a microprocessor in the electronic device to execute at least a portion of a set of code to control the electronic device, wherein The plurality of operations of the electronic device include a predetermined operation, the set of code includes a predetermined program module for controlling the predetermined operation, the predetermined program module includes a partial program, and the partial program provides a And the variable accessing service to the predetermined program module; and executing the partial program by the microprocessor to control the electronic device to perform the predetermined operation, wherein executing the partial program to control the electronic device to perform the predetermined operation comprises: corresponding The data of an index is copied from a data storage area corresponding to the index to at least one shared variable in a shared memory storage area, wherein the at least one shared variable is a non-array variable (non- Array variable); operating the data in the at least one shared variable to control the electronic device to perform the At least a portion of the operation, wherein operating the data in the at least one shared variable comprises accessing the material in the at least one shared variable; and updating the latest data in the at least one shared variable from the shared memory storage area Copying the at least one shared variable to the data storage area corresponding to the index; wherein, through the variable access service, all required array variables in the predetermined program module have been replaced with respect to the at least one shared variable a plurality of access operations to reduce a machine code size of the predetermined program module in a memory of the electronic device, wherein the machine code amount represents the predetermined program module in the memory size. 一種用來於一電子裝置中進行硬體資源管理之方法,該方法包含有:利用該電子裝置中之一微處理器(microcontroller)執行一組程式碼之至少一部分,以控制該電子裝置,其中該電子裝置之多個運作包含一預定運作,該組程式碼包含用來控制該預定運作之一預定程式模組,該預定程式模組包含一局部程式(partial program),且該局部程式提供一變數存取服務予該預定程式模組;以及利用該微處理器執行該局部程式,以控制該電子裝置進行該預定運作,其中執行該局部程式以控制該電子裝置進行該預定運作包含:將對應於一索引之資料從對應於該索引之一資料儲存區複製到一共享記憶體(shared memory)儲存區中之至少一共享變數(shared variable),其中該至少一共享變數是非陣列變數(non-array variable);操作(operate)該至少一共享變數中之該資料,以控制該電子裝置進行該預定運作之至少一部分,其中操作該至少一共享變數中之該資料包含存取該至少一共享變數中之該資料;以及將該至少一共享變數中之最新資料從該共享記憶體儲存區中之該至少一共享變數複製到對應於該索引之該資料儲存區;其中,透過該變數存取服務,當該組程式碼被載入(load)到該電子裝置之一記憶體時,該組程式碼中之該預定程式模組已變小。 A method for hardware resource management in an electronic device, the method comprising: using a microprocessor in the electronic device to execute at least a portion of a set of code to control the electronic device, wherein The plurality of operations of the electronic device include a predetermined operation, the set of code includes a predetermined program module for controlling the predetermined operation, the predetermined program module includes a partial program, and the partial program provides a And the variable accessing service to the predetermined program module; and executing the partial program by the microprocessor to control the electronic device to perform the predetermined operation, wherein executing the partial program to control the electronic device to perform the predetermined operation comprises: corresponding The data of an index is copied from a data storage area corresponding to the index to at least one shared variable in a shared memory storage area, wherein the at least one shared variable is a non-array variable (non- Array variable); operating the data in the at least one shared variable to control the electronic device to perform the At least a portion of the operation, wherein operating the data in the at least one shared variable comprises accessing the material in the at least one shared variable; and updating the latest data in the at least one shared variable from the shared memory storage area Copying the at least one shared variable to the data storage area corresponding to the index; wherein, through the variable access service, when the set of code is loaded into a memory of the electronic device, the set of programs The predetermined program module in the code has become smaller. 一種用來於一電子裝置中進行硬體資源管理之方法,該方法包含有:利用該電子裝置中之一微處理器(microcontroller)執行一組程式碼之至少一部分,以控制該電子裝置,其中該電子裝置之多個運作包含一預 定運作,該組程式碼包含用來控制該預定運作之一預定程式模組,該預定程式模組包含一局部程式(partial program),且該局部程式提供一變數存取服務予該預定程式模組;以及利用該微處理器執行該局部程式,以控制該電子裝置進行該預定運作,其中執行該局部程式以控制該電子裝置進行該預定運作包含:將對應於一索引之資料從對應於該索引之一資料儲存區複製到一共享記憶體(shared memory)儲存區中之至少一共享變數(shared variable),其中該至少一共享變數是非陣列變數(non-array variable);操作(operate)該至少一共享變數中之該資料,以控制該電子裝置進行該預定運作之至少一部分,其中操作該至少一共享變數中之該資料包含存取該至少一共享變數中之該資料;以及將該至少一共享變數中之最新資料從該共享記憶體儲存區中之該至少一共享變數複製到對應於該索引之該資料儲存區;其中該電子裝置之該多個運作分別對應於該電子裝置之多個功能,且該預定運作對應於該多個功能中之一預定功能;以及該方法另包含:將該組程式碼載入(load)到該電子裝置之一記憶體,以容許該微處理器執行該組程式碼,其中透過該變數存取服務,該組程式碼當中對應於該預定功能之程式碼已變小,以於該記憶體中保留儲存空間給該組程式碼當中對應於其它功能之程式碼。 A method for hardware resource management in an electronic device, the method comprising: using a microprocessor in the electronic device to execute at least a portion of a set of code to control the electronic device, wherein The multiple operations of the electronic device include a pre- The program code includes a predetermined program module for controlling the predetermined operation, the predetermined program module includes a partial program, and the partial program provides a variable access service to the predetermined program module. And executing the local program by the microprocessor to control the electronic device to perform the predetermined operation, wherein executing the partial program to control the electronic device to perform the predetermined operation comprises: corresponding data corresponding to an index from the group One of the index data storage areas is copied to at least one shared variable in a shared memory storage area, wherein the at least one shared variable is a non-array variable; the operation is operated Relying at least one of the data in the variable to control the electronic device to perform at least a portion of the predetermined operation, wherein operating the data in the at least one shared variable comprises accessing the material in the at least one shared variable; and The latest data in a shared variable is copied from the at least one shared variable in the shared memory storage area to correspond to Indexing the data storage area; wherein the plurality of operations of the electronic device respectively correspond to a plurality of functions of the electronic device, and the predetermined operation corresponds to one of the plurality of functions; and the method further comprises: The set of code is loaded into a memory of the electronic device to allow the microprocessor to execute the set of code, wherein the variable access service, the program corresponding to the predetermined function among the set of codes The code has become smaller so that the memory is reserved in the memory for the code corresponding to other functions in the set of codes. 如申請專利範圍第9項所述之方法,其中該記憶體包含多個資料儲存區,且該多個資料儲存區包含該共享記憶體儲存區以及對應於該索引之該資料儲存區。 The method of claim 9, wherein the memory comprises a plurality of data storage areas, and the plurality of data storage areas comprise the shared memory storage area and the data storage area corresponding to the index. 一種電子裝置,包含有:一記憶體,用來儲存該電子裝置之一組程式碼;以及一微處理器(microcontroller),耦接至該記憶體,用來執行該組程式碼之至少一部分,以控制該電子裝置,其中該電子裝置之多個運作包含一預定運作,該組程式碼包含用來控制該預定運作之一預定程式模組,該預定程式模組包含一局部程式(partial program),且該局部程式提供一變數存取服務予該預定程式模組;其中,該微處理器執行該局部程式,以控制該電子裝置進行該預定運作,其中執行該局部程式以控制該電子裝置進行該預定運作包含:將對應於一索引之資料從對應於該索引之一資料儲存區複製到一共享記憶體(shared memory)儲存區中之多個共享變數(shared variable),其中該多個共享變數是非陣列變數(non-array variable),且該多個資料儲存區包含該共享記憶體儲存區以及對應於該索引之該資料儲存區;分別操作(operate)該多個共享變數中之該資料,以控制該電子裝置進行該預定運作之至少一部分,其中分別操作該多個共享變數中之該資料包含分別存取該多個共享變數中之該資料;以及將該多個共享變數中之最新資料從該共享記憶體儲存區中之該多個共享變數複製到對應於該索引之該資料儲存區。 An electronic device includes: a memory for storing a set of code of the electronic device; and a microprocessor coupled to the memory for executing at least a part of the set of codes, To control the electronic device, wherein the plurality of operations of the electronic device comprise a predetermined operation, the set of code includes a predetermined program module for controlling the predetermined operation, the predetermined program module including a partial program And the local program provides a variable access service to the predetermined program module; wherein the microprocessor executes the local program to control the electronic device to perform the predetermined operation, wherein the local program is executed to control the electronic device The predetermined operation includes: copying data corresponding to an index from a data storage area corresponding to the index to a plurality of shared variables in a shared memory storage area, wherein the multiple shares are shared The variable is a non-array variable, and the plurality of data storage areas include the shared memory storage area and corresponding to the cable The data storage area; respectively operating the data of the plurality of shared variables to control the electronic device to perform at least a part of the predetermined operation, wherein respectively operating the data of the plurality of shared variables comprises separately accessing The data in the plurality of shared variables; and copying the latest data of the plurality of shared variables from the plurality of shared variables in the shared memory storage area to the data storage area corresponding to the index. 如申請專利範圍第11項所述之電子裝置,其中分別操作該多個共享變數中之該資料另包含:分別將多個運算子施加於(apply to)該多個共享變數中之該資料,以產生 該多個共享變數中之該最新資料。 The electronic device of claim 11, wherein operating the data of the plurality of shared variables separately comprises: applying a plurality of operators to the plurality of shared variables, respectively, To produce The latest information in the plurality of shared variables. 一種電子裝置,包含有:一記憶體,用來儲存該電子裝置之一組程式碼;以及一微處理器(microcontroller),耦接至該記憶體,用來執行該組程式碼之至少一部分,以控制該電子裝置,其中該電子裝置之多個運作包含一預定運作,該組程式碼包含用來控制該預定運作之一預定程式模組,該預定程式模組包含一局部程式(partial program),且該局部程式提供一變數存取服務予該預定程式模組;其中,該微處理器執行該局部程式,以控制該電子裝置進行該預定運作,其中執行該局部程式以控制該電子裝置進行該預定運作包含:將對應於一索引之資料從對應於該索引之一資料儲存區複製到一共享記憶體(shared memory)儲存區中之至少一共享變數(shared variable),其中該至少一共享變數是非陣列變數(non-array variable),且該多個資料儲存區包含該共享記憶體儲存區以及對應於該索引之該資料儲存區;操作(operate)該至少一共享變數中之該資料,以控制該電子裝置進行該預定運作之至少一部分,其中操作該至少一共享變數中之該資料包含存取該至少一共享變數中之該資料;以及將該至少一共享變數中之最新資料從該共享記憶體儲存區中之該至少一共享變數複製到對應於該索引之該資料儲存區;其中該局部程式提供該變數存取服務予該預定程式模組,以減少該預定程式模組存取(access)陣列變數(array variable)的機會。 An electronic device includes: a memory for storing a set of code of the electronic device; and a microprocessor coupled to the memory for executing at least a part of the set of codes, To control the electronic device, wherein the plurality of operations of the electronic device comprise a predetermined operation, the set of code includes a predetermined program module for controlling the predetermined operation, the predetermined program module including a partial program And the local program provides a variable access service to the predetermined program module; wherein the microprocessor executes the local program to control the electronic device to perform the predetermined operation, wherein the local program is executed to control the electronic device The predetermined operation includes: copying data corresponding to an index from a data storage area corresponding to the index to at least one shared variable in a shared memory storage area, wherein the at least one sharing The variable is a non-array variable, and the plurality of data storage areas include the shared memory storage area and corresponding to Indexing the data storage area; operating the data in the at least one shared variable to control the electronic device to perform at least a portion of the predetermined operation, wherein operating the data in the at least one shared variable comprises accessing the at least Copying the data in a shared variable; and copying the latest data of the at least one shared variable from the at least one shared variable in the shared memory storage area to the data storage area corresponding to the index; wherein the local program provides The variable access service is provided to the predetermined program module to reduce the chance that the predetermined program module accesses an array variable. 如申請專利範圍第13項所述之電子裝置,其中操作該至少一共享變數中之該資料另包含:將至少一運算子施加於(apply to)該至少一共享變數中之該資料,以產生該至少一共享變數中之該最新資料。 The electronic device of claim 13, wherein operating the data in the at least one shared variable further comprises: applying at least one operator to the data in the at least one shared variable to generate The latest information in the at least one shared variable. 一種電子裝置,包含有:一記憶體,用來儲存該電子裝置之一組程式碼;以及一微處理器(microcontroller),耦接至該記憶體,用來執行該組程式碼之至少一部分,以控制該電子裝置,其中該電子裝置之多個運作包含一預定運作,該組程式碼包含用來控制該預定運作之一預定程式模組,該預定程式模組包含一局部程式(partial program),且該局部程式提供一變數存取服務予該預定程式模組;其中,該微處理器執行該局部程式,以控制該電子裝置進行該預定運作,其中執行該局部程式以控制該電子裝置進行該預定運作包含:將對應於一索引之資料從對應於該索引之一資料儲存區複製到一共享記憶體(shared memory)儲存區中之至少一共享變數(shared variable),其中該至少一共享變數是非陣列變數(non-array variable),且該多個資料儲存區包含該共享記憶體儲存區以及對應於該索引之該資料儲存區;操作(operate)該至少一共享變數中之該資料,以控制該電子裝置進行該預定運作之至少一部分,其中操作該至少一共享變數中之該資料包含存取該至少一共享變數中之該資料;以及將該至少一共享變數中之最新資料從該共享記憶體儲存區中之該至少一共享變數複製到對應於該索引之該資料儲存區; 其中透過該變數存取服務,該組程式碼中之至少一部分程式碼之機器碼量(machine code size)已變小,使該記憶體的儲存容量足以儲存該組程式碼。 An electronic device includes: a memory for storing a set of code of the electronic device; and a microprocessor coupled to the memory for executing at least a part of the set of codes, To control the electronic device, wherein the plurality of operations of the electronic device comprise a predetermined operation, the set of code includes a predetermined program module for controlling the predetermined operation, the predetermined program module including a partial program And the local program provides a variable access service to the predetermined program module; wherein the microprocessor executes the local program to control the electronic device to perform the predetermined operation, wherein the local program is executed to control the electronic device The predetermined operation includes: copying data corresponding to an index from a data storage area corresponding to the index to at least one shared variable in a shared memory storage area, wherein the at least one sharing The variable is a non-array variable, and the plurality of data storage areas include the shared memory storage area and corresponding to Indexing the data storage area; operating the data in the at least one shared variable to control the electronic device to perform at least a portion of the predetermined operation, wherein operating the data in the at least one shared variable comprises accessing the at least Copying the data in a shared variable; and copying the latest data of the at least one shared variable from the at least one shared variable in the shared memory storage area to the data storage area corresponding to the index; Through the variable access service, the machine code size of at least a part of the code of the set of codes has become smaller, so that the storage capacity of the memory is sufficient to store the set of codes. 如申請專利範圍第15項所述之電子裝置,其中操作該至少一共享變數中之該資料另包含:將至少一運算子施加於(apply to)該至少一共享變數中之該資料,以產生該至少一共享變數中之該最新資料。 The electronic device of claim 15, wherein the operating the data in the at least one shared variable further comprises: applying at least one operator to the data in the at least one shared variable to generate The latest information in the at least one shared variable. 一種電子裝置,包含有:一記憶體,用來儲存該電子裝置之一組程式碼;以及一微處理器(microcontroller),耦接至該記憶體,用來執行該組程式碼之至少一部分,以控制該電子裝置,其中該電子裝置之多個運作包含一預定運作,該組程式碼包含用來控制該預定運作之一預定程式模組,該預定程式模組包含一局部程式(partial program),且該局部程式提供一變數存取服務予該預定程式模組;其中,該微處理器執行該局部程式,以控制該電子裝置進行該預定運作,其中執行該局部程式以控制該電子裝置進行該預定運作包含:將對應於一索引之資料從對應於該索引之一資料儲存區複製到一共享記憶體(shared memory)儲存區中之至少一共享變數(shared variable),其中該至少一共享變數是非陣列變數(non-array variable),且該多個資料儲存區包含該共享記憶體儲存區以及對應於該索引之該資料儲存區;操作(operate)該至少一共享變數中之該資料,以控制該電子裝置進行該預定運作之至少一部分,其中操作該至少一共享變數中 之該資料包含存取該至少一共享變數中之該資料;以及將該至少一共享變數中之最新資料從該共享記憶體儲存區中之該至少一共享變數複製到對應於該索引之該資料儲存區;其中,透過該變數存取服務,該預定程式模組中之所有需要陣列變數之處已分別被取代為關於該至少一共享變數之多個存取運作,以減少該預定程式模組於該記憶體中之機器碼量(machine code size),其中該機器碼量代表該預定程式模組於該記憶體中之大小。 An electronic device includes: a memory for storing a set of code of the electronic device; and a microprocessor coupled to the memory for executing at least a part of the set of codes, To control the electronic device, wherein the plurality of operations of the electronic device comprise a predetermined operation, the set of code includes a predetermined program module for controlling the predetermined operation, the predetermined program module including a partial program And the local program provides a variable access service to the predetermined program module; wherein the microprocessor executes the local program to control the electronic device to perform the predetermined operation, wherein the local program is executed to control the electronic device The predetermined operation includes: copying data corresponding to an index from a data storage area corresponding to the index to at least one shared variable in a shared memory storage area, wherein the at least one sharing The variable is a non-array variable, and the plurality of data storage areas include the shared memory storage area and corresponding to The index of the data store; operation (Operate) in which at least one of the shared data variable, the electronic device to control the operation of at least a portion of the predetermined, wherein the at least one operation in the shared variable The data includes accessing the data in the at least one shared variable; and copying the latest data of the at least one shared variable from the at least one shared variable in the shared memory storage area to the data corresponding to the index a storage area in which all of the array variables required in the predetermined program module have been replaced with a plurality of access operations for the at least one shared variable to reduce the predetermined program module; A machine code size in the memory, wherein the machine code amount represents a size of the predetermined program module in the memory. 一種電子裝置,包含有:一記憶體,用來儲存該電子裝置之一組程式碼;以及一微處理器(microcontroller),耦接至該記憶體,用來執行該組程式碼之至少一部分,以控制該電子裝置,其中該電子裝置之多個運作包含一預定運作,該組程式碼包含用來控制該預定運作之一預定程式模組,該預定程式模組包含一局部程式(partial program),且該局部程式提供一變數存取服務予該預定程式模組;其中,該微處理器執行該局部程式,以控制該電子裝置進行該預定運作,其中執行該局部程式以控制該電子裝置進行該預定運作包含:將對應於一索引之資料從對應於該索引之一資料儲存區複製到一共享記憶體(shared memory)儲存區中之至少一共享變數(shared variable),其中該至少一共享變數是非陣列變數(non-array variable),且該多個資料儲存區包含該共享記憶體儲存區以及對應於該索引之該資料儲存區;操作(operate)該至少一共享變數中之該資料,以控制該電子裝置進行該預定運作之至少一部分,其中操作該至少一共享變數中 之該資料包含存取該至少一共享變數中之該資料;以及將該至少一共享變數中之最新資料從該共享記憶體儲存區中之該至少一共享變數複製到對應於該索引之該資料儲存區;其中,透過該變數存取服務,當該組程式碼被載入(load)到該記憶體時,該組程式碼中之該預定程式模組已變小。 An electronic device includes: a memory for storing a set of code of the electronic device; and a microprocessor coupled to the memory for executing at least a part of the set of codes, To control the electronic device, wherein the plurality of operations of the electronic device comprise a predetermined operation, the set of code includes a predetermined program module for controlling the predetermined operation, the predetermined program module including a partial program And the local program provides a variable access service to the predetermined program module; wherein the microprocessor executes the local program to control the electronic device to perform the predetermined operation, wherein the local program is executed to control the electronic device The predetermined operation includes: copying data corresponding to an index from a data storage area corresponding to the index to at least one shared variable in a shared memory storage area, wherein the at least one sharing The variable is a non-array variable, and the plurality of data storage areas include the shared memory storage area and corresponding to The index of the data store; operation (Operate) in which at least one of the shared data variable, the electronic device to control the operation of at least a portion of the predetermined, wherein the at least one operation in the shared variable The data includes accessing the data in the at least one shared variable; and copying the latest data of the at least one shared variable from the at least one shared variable in the shared memory storage area to the data corresponding to the index a storage area; wherein, through the variable access service, when the set of code is loaded into the memory, the predetermined program module in the set of codes has become smaller. 一種電子裝置,包含有:一記憶體,用來儲存該電子裝置之一組程式碼;以及一微處理器(microcontroller),耦接至該記憶體,用來執行該組程式碼之至少一部分,以控制該電子裝置,其中該電子裝置之多個運作包含一預定運作,該組程式碼包含用來控制該預定運作之一預定程式模組,該預定程式模組包含一局部程式(partial program),且該局部程式提供一變數存取服務予該預定程式模組;其中,該微處理器執行該局部程式,以控制該電子裝置進行該預定運作,其中執行該局部程式以控制該電子裝置進行該預定運作包含:將對應於一索引之資料從對應於該索引之一資料儲存區複製到一共享記憶體(shared memory)儲存區中之至少一共享變數(shared variable),其中該至少一共享變數是非陣列變數(non-array variable),且該多個資料儲存區包含該共享記憶體儲存區以及對應於該索引之該資料儲存區;操作(operate)該至少一共享變數中之該資料,以控制該電子裝置進行該預定運作之至少一部分,其中操作該至少一共享變數中之該資料包含存取該至少一共享變數中之該資料;以及將該至少一共享變數中之最新資料從該共享記憶體儲存區中之該至 少一共享變數複製到對應於該索引之該資料儲存區;其中該電子裝置之該多個運作分別對應於該電子裝置之多個功能,且該預定運作對應於該多個功能中之一預定功能;以及該電子裝置將該組程式碼載入(load)到該記憶體,以容許該微處理器執行該組程式碼,其中透過該變數存取服務,該組程式碼當中對應於該預定功能之程式碼已變小,以於記憶體中保留儲存空間給該組程式碼當中對應於其它功能之程式碼。 An electronic device includes: a memory for storing a set of code of the electronic device; and a microprocessor coupled to the memory for executing at least a part of the set of codes, To control the electronic device, wherein the plurality of operations of the electronic device comprise a predetermined operation, the set of code includes a predetermined program module for controlling the predetermined operation, the predetermined program module including a partial program And the local program provides a variable access service to the predetermined program module; wherein the microprocessor executes the local program to control the electronic device to perform the predetermined operation, wherein the local program is executed to control the electronic device The predetermined operation includes: copying data corresponding to an index from a data storage area corresponding to the index to at least one shared variable in a shared memory storage area, wherein the at least one sharing The variable is a non-array variable, and the plurality of data storage areas include the shared memory storage area and corresponding to Indexing the data storage area; operating the data in the at least one shared variable to control the electronic device to perform at least a portion of the predetermined operation, wherein operating the data in the at least one shared variable comprises accessing the at least The data in a shared variable; and the latest data in the at least one shared variable from the shared memory storage area Copying a shared variable to the data storage area corresponding to the index; wherein the plurality of operations of the electronic device respectively correspond to a plurality of functions of the electronic device, and the predetermined operation corresponds to one of the plurality of functions And loading, by the electronic device, the set of code into the memory to allow the microprocessor to execute the set of code, wherein the set of code corresponds to the predetermined through the variable access service The function code has been reduced to reserve storage space in the memory for the code corresponding to other functions in the set of codes.
TW106129241A 2017-08-29 2017-08-29 Method for performing hardware resource management in an electronic device, and corresponding electronic device TWI647619B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
TW106129241A TWI647619B (en) 2017-08-29 2017-08-29 Method for performing hardware resource management in an electronic device, and corresponding electronic device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
TW106129241A TWI647619B (en) 2017-08-29 2017-08-29 Method for performing hardware resource management in an electronic device, and corresponding electronic device

Publications (2)

Publication Number Publication Date
TWI647619B true TWI647619B (en) 2019-01-11
TW201913371A TW201913371A (en) 2019-04-01

Family

ID=65804153

Family Applications (1)

Application Number Title Priority Date Filing Date
TW106129241A TWI647619B (en) 2017-08-29 2017-08-29 Method for performing hardware resource management in an electronic device, and corresponding electronic device

Country Status (1)

Country Link
TW (1) TWI647619B (en)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
TW200403588A (en) * 2001-12-31 2004-03-01 Intel Corp Suspending execution of a thread in a multi-threaded processor
US20060200326A1 (en) * 2005-03-07 2006-09-07 Heumann John M Radiographic imaging systems and methods for designing same
TW201439907A (en) * 2012-11-05 2014-10-16 Nvidia Corp System and method for translating program functions for correct handling of local-scope variables and computing system incorporating the same

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
TW200403588A (en) * 2001-12-31 2004-03-01 Intel Corp Suspending execution of a thread in a multi-threaded processor
US20060200326A1 (en) * 2005-03-07 2006-09-07 Heumann John M Radiographic imaging systems and methods for designing same
TW201439907A (en) * 2012-11-05 2014-10-16 Nvidia Corp System and method for translating program functions for correct handling of local-scope variables and computing system incorporating the same

Also Published As

Publication number Publication date
TW201913371A (en) 2019-04-01

Similar Documents

Publication Publication Date Title
TWI403954B (en) Electronic system, microcontrollers with instruction sets and method for executing instruction thererof
JP3892851B2 (en) Memory card and semiconductor device
TWI461910B (en) Memories and methods for performing atomic memory operations in accordance with configuration information
US8015344B2 (en) Apparatus and method for processing data of flash memory
JP7088897B2 (en) Data access methods, data access devices, equipment and storage media
JP2004258946A (en) Memory card
KR20170140225A (en) Central Processing Unit with Enhanced Instruction Set
US11481315B2 (en) Booting an application from multiple memories
US20100153619A1 (en) Data processing and addressing methods for use in an electronic apparatus
CN111797390B (en) Program running method, program running device, electronic equipment and computer readable storage medium
TWI647619B (en) Method for performing hardware resource management in an electronic device, and corresponding electronic device
KR102130813B1 (en) Re-configurable processor and method for operating re-configurable processor
US11422742B2 (en) Allocation of memory
CN109471673B (en) Method for hardware resource management in electronic device and electronic device
JP2005182538A (en) Data transfer device
TWI705372B (en) Flash memory device and controlling method thereof
JP2013254357A (en) Information processing apparatus and method, and program
TWI811633B (en) Electronic device and operation method thereof
US20240134572A1 (en) Allocation of memory by mapping registers referenced by different instances of a task to individual logical memories
EP3834090B1 (en) Fast initialization of complex in-memory data structures
JP2012168737A (en) Memory unit
JP6103972B2 (en) Program generation method, program execution method, program execution device, and program execution program
Zambon et al. Dynamic Arrays
JPH02130654A (en) Computer device
JP2018151692A (en) Calculator and application management method