Method and electronic device of file system prefetching and boot-up method

A method of file system prefetching is provided. The method is applicable to an electronic device including a volatile storage, a non-volatile storage, and multiple processors with multiple operating systems. The method includes the following steps. When a first static backup table in the non-volatile storage is not empty, copy all data in the first static backup table to a second static backup table in the volatile storage. Check whether the first static backup table includes all required data for booting one of the operating systems in a static partition of the non-volatile storage. When the first static backup table does not include all of the required data, copy a part of the remaining required data in the static partition to the first and the second static backup tables. Return to the checking step when a booting state synchronization of the operating systems is not completed yet.

BACKGROUND OF THE INVENTION

1. Field of the Invention

The present invention relates to a method and an electronic device of file system prefetching and a boot-up method. More particularly, the present invention relates to a method of file system prefetching during booting multiple operating systems (OS), an electronic device executing the method, and a corresponding boot-up method.

2. Description of the Related Art

A mobile device today, such as a smart phone, tablet computer, personal digital assistant (PDA), game console and the like, may include multiple processors. The multiple processors may execute multiple operating systems. For example, the main processor may execute the main operating system that provides applications and graphical user interfaces to serve the user, while an auxiliary processor may execute an embedded operating system to control a peripheral device, such as a wireless communication module of the mobile device.

In a typical multi-processor mobile device, the processors may operate according to different clock frequencies and the operating systems may have different levels of complexity. As a result, the time each processor takes to boot up the corresponding operating system is different. When the power of a multi-processor mobile device is powered on, each processor begins to boot up its operating system. The processors have to perform a booting state synchronization for establishing the communication mechanism among the processors and synchronizing the booting states of the operating systems to ensure a correct booting of the multi-processor multi-system mobile device.

After the booting state synchronization, the main operating system running on the main processor copies the data required for booting the main operating system from a slower non-volatile storage, such as a flash memory, to a faster volatile storage, such as a dynamic random-access memory (DRAM). The main operating system accesses the aforementioned data stored in the volatile storage during its booting sequence.

The bottleneck of booting the main operating system usually occurs on the aforementioned data copy from the non-volatile storage to the volatile storage. For example, the data copy may take 40% of the total booting time of the mobile device.

SUMMARY OF THE INVENTION

Accordingly, the present invention is directed to a method and an electronic device of file system prefetching and a boot-up method. The present invention can shorten the booting time of an electronic device with multiple processors and multiple operating systems by interleaving the time waiting for the booting state synchronization and the data copy from the non-volatile storage to the volatile storage.

According to an embodiment of the present invention, a method of file system prefetching is provided. The method is applicable to an electronic device including a volatile storage, a non-volatile storage, and a plurality of processors with a plurality of operating systems. The method includes the following steps. When a first static backup table in the non-volatile storage is not empty, copy all data in the first static backup table to a second static backup table in the volatile storage. Check whether the first static backup table includes all required data for booting one of the operating systems in a static partition of the non-volatile storage or not. When the first static backup table does not include all of the required data in the static partition, copy a part of the remaining required data in the static partition to the first and the second static backup tables. When a booting state synchronization of the operating systems is not completed yet, return to the step of checking whether the first static backup table includes all of the required data in the static partition or not.

According to another embodiment of the present invention, an electronic device of file system prefetching is provided. The electronic device includes a volatile storage, a non-volatile storage, and a plurality of processors with a plurality of operating systems. One of the plurality of processors is a main processor and the other ones of the plurality of processors are auxiliary processors. The main processor is coupled to the volatile storage, the non-volatile storage and the auxiliary processors. The main processor executes the aforementioned method of file system prefetching.

According to another embodiment of the present invention, a boot-up method for use in an electronic device including at least two processors is provided. The at least two processors run on at least two operating systems (OS). The boot-up method includes the following steps. Power up the electronic device. Execute system boot-up procedures corresponding to the at least two processors in parallel. Determine whether a first processor of the at least two processors completes the system boot-up procedure. In response to a second processor of the at least two processors being still booting, load at least a first portion of a data file from a first storage unit to a second storage unit. Determine whether the second processor completes the system boot-up procedure. In response to the second processor completing the system boot-up procedure, execute an OS boot-up procedure corresponding to the data file by the first processor.

DESCRIPTION OF THE EMBODIMENTS

First please refer toFIG. 1, which depicts a diagram of file system prefetching according to an embodiment of the present invention. While booting up of an electronic device, the main processor110and the auxiliary processor120load operating system1and operating system2respectively. Upon completion of loading operating systems, the processors then create their own file systems (FS). The file system is stored in a non-volatile storage (NV storage) and would be copied to volatile storage (V storage) which has faster access speed to improve performance. However, the booting progress of main processor110and auxiliary processor120may not be in sync. As can be observed inFIG. 1, the auxiliary processor120takes longer time to load operating system2. Therefore the main processor110would prefetch image of file system of the electronic device, which may include necessary information to configure the electronic device, from non-volatile storage to volatile storage prior to the auxiliary processor120completing loading of operating system2. In the embodiment of the present invention, the main processor110may prefetch one fixed size of the file system at a time, for example N bytes at a time, to a predefined memory space within the volatile storage. The size N may be predefined or dynamically changed and the predefined memory space is allocated for prefetching only. When the auxiliary processor120completes loading of operating system2and sends a status sync signal to the main processor110, prefetching of the file system may be terminated.

After synchronization of booting process among the main processor110and the auxiliary processor120, the main processor110may proceed with normal file system creation. Due to some portion of the file system has already been prefetched, the main processor110may continue by performing hit/miss test in the volatile storage and access other portion of the file system that is not yet prefetched (missed) into the volatile storage from the non-volatile storage. The portion of the image of the file system which is fetched in normal procedure would be erased from the volatile storage when the electronic device is powered down and thus needs to be accessed again from non-volatile storage in next boot up procedure. Please note that the prefetched portion of the image of the file system would not be erased from the volatile storage and upon next boot up of the electronic device, the main processor110may continue to prefetch other portion of the file system from the non-volatile storage to the volatile storage. As a result, the time required to create the file system would be reduced after each time the electronic device is powered up with booting process.

FIG. 2is a schematic diagram showing a prefetch memory according to an embodiment of the present invention. The non-volatile storage250may store, among other, OS 1 boot data, image of file system, user data, and a copy of a portion of OS 1 boot data. The volatile storage240is allocated with a predefined memory space for storing prefetched data, comprising the image of file system and the portion of OS 1 boot data. The address range of the volatile storage240that has been filled with prefetched data may be recorded, and upon the next prefetch operation, the main processor110may continue to store prefetched data to the next location of the predefined memory space.

FIG. 3is a schematic diagram showing an electronic device300of file system prefetching according to an embodiment of the present invention. The electronic device300may be a mobile device such as a smart phone, a personal digital assistant (PDA), a tablet computer, a game console, or a media player, etc. Alternatively, the electronic device300may be any electronic device including multiple processors executing multiple operating systems.

The electronic device300includes a volatile storage350, a non-volatile storage340, a main processor310, and an auxiliary processor320. The access speed of the volatile storage350is faster than that of the non-volatile storage340. The volatile storage350may be a random-access memory (RAM). The non-volatile storage340may be a hard disk, a memory stick, a memory card, a flash memory, or an embedded multimedia card (eMMC).

The main processor310executes the main operating system315of the electronic device300. The main operating system315provides the applications and graphical user interfaces accessible to the user. The auxiliary processor320executes another operating system325for performing specific functions. The operating system325may control a part of the hardware of the electronic device300. The main processor310is coupled to the volatile storage350, the non-volatile storage340and the auxiliary processor320.

The non-volatile storage340includes a static partition346and a dynamic partition348. The static partition346and the dynamic partition348include the file system of the main operating system315. The static partition346stores the data of the operating system315, such as applications, device drivers and software libraries of the operating system315. The data in the static partition346are unchangeable (read-only), which means the data in the static partition346are always the same every time when the main operating system315is booted up. On the other hand, the dynamic partition348stores the data of the user of the electronic device300, such as documents created by the user or data downloaded by the user. The data in the dynamic partition348are changeable, which means the user can modify them. Therefore, the data in the dynamic partition348may be different every time when the main operating system315is booted up.

The non-volatile storage340includes a static backup table342. The volatile storage350includes another static backup table352. Each of the static backup tables342and352is configured for storing all of the required data for booting the main operating system315in the static partition346. The volatile storage350includes a dynamic prefetch table354. The dynamic prefetch table354is configured for storing all of the required data for booting the main operating system315in the dynamic partition348.

In some other embodiments of the present invention, the electronic device300may include more than two processors. In this general case, one of the processors is a main processor and the other processors are auxiliary processors. Each of the main processor and the auxiliary processors executes an operating system. The main processor is coupled to the volatile storage, the non-volatile storage and each of the auxiliary processors of the electronic device300.

The main operating system315requires some data for its booting sequence, such as applications, device drivers and software libraries. Some of the required data are stored in the static partition346and some of the required data are stored in the dynamic partition348. These required data have to be copied from the non-volatile storage340to the volatile storage350for the main operating system315to access them. Since the speed of the main processor310is faster than that of the auxiliary processor320, the main processor310has some time to prefetch the required data for booting the main operating system315from the partitions346and348into the tables342,352and354while waiting for the auxiliary processor320to complete the booting state synchronization of the operating systems315and325. The prefetching of the required data is performed by a method of file system prefetching shown inFIG. 4.

FIG. 4is a flow chart showing a method of file system prefetching according to an embodiment of the present invention. The method of file system prefetching may be executed by a main processor of an electronic device including a non-volatile storage, a volatile storage, multiple processors and multiple operating systems, such as the main processor310of the electronic device300. After the power of the electronic device300is turned on, the main processor310finishes its own initialization and then begins to boot up the main operating system315. This is the moment when the main processor310executes the method of file system prefetching.

The flow of the method of file system prefetching is recited below. At step405, check whether the static backup table342in the non-volatile storage340is empty or not. When the static backup table342is empty, the flow proceeds to step420. When the static backup table342is not empty, the flow proceeds to step410. At step410, copy all of the data in the static backup table342to the static backup table352in the volatile storage350. The data stored in the static backup table352will be used in the booting sequence of the main operating system315.

Next, at step415, check whether the static backup table342includes all of the required data for booting the main operating systems315in the static partition346or not. When the static backup table342already includes all of the required data in the static partition346, the flow proceeds to step425. When the static backup table342does not include all of the required data in the static partition346, the flow proceeds to step420to copy a part of the remaining required data in the static partition346to both the static backup tables342and352. The prefetching of the required data from the static partition346to each of the static backup tables342and352is performed synchronously. When a piece of the required data is copied from the static partition346to the static backup table3422, the same piece of the required data is also copied to the static backup table352at the same time.

Next, at step435, check whether the booting state synchronization of all of the operating systems in the electronic device300is completed or not. When the power of the electronic device300is turned on, all processors of the electronic device300have to perform a booting state synchronization for establishing the communication mechanism among all of the processors and synchronizing the booting states of all of the operating systems to ensure a correct booting of the electronic device300. When the booting state synchronization is completed, the flow proceeds to step440. When the booting state synchronization is not completed yet, the flow returns to step415to repeat the static prefetching loop formed by steps415,420and435.

The required data copied to the static backup table352will be used in the following booting sequence of the main operating system315. The required data copied to the static backup table342can be copied to the static backup table352at step410next time when the method of file system prefetching is executed. The required data stored in the static partition346may be fragmented and widely distributed. At step420, the main processor310stores the required data in the static partition346into the static backup tables342and352in a contiguous and defragmented way. Since the data in the static backup table342is defragmented, copying the required data from the static backup table342to the static backup table352is faster than copying the required data from the static partition346to the static backup table352. This helps to shorten the booting time of the electronic device300. Moreover, since the static backup table342is stored in the non-volatile storage340, the data in the static backup table342do not volatilize after the power of the electronic device300is turned off. Next time when the power of the electronic device300is turned on, the data already stored in the static backup table342do not need to be copied again. This also helps to shorten the booting time of the electronic device300.

When the static backup table342includes all of the required data for booting the main operating systems315in the static partition346, the flow proceeds from step415to step425. At step425, check whether the dynamic prefetch table354in the volatile storage350includes all of the required data for booting the main operating system315in the dynamic partition348or not. When the dynamic prefetch table354already includes all of the required data in the dynamic partition348, the flow proceeds to step435. When the dynamic prefetch table354does not include all of the required data in the dynamic partition348, the flow proceeds to step430to copy a part of the remaining required data in the dynamic partition348to the dynamic prefetch table354.

Next, at step435, check whether the processors complete the booting state synchronization or not. When the booting state synchronization is completed, the flow proceeds to step440. When the booting state synchronization is not completed yet, the flow returns to step425to repeat the dynamic fetching loop formed by steps425,430and435. The required data copied to the dynamic prefetch table354will be used in the following booting sequence of the main operating system315. Since the dynamic prefetch table354is stored in the volatile storage350, the data in the dynamic prefetch table354are copied from scratch each time when the power of the electronic device300is turned on.

When the dynamic prefetch table354includes all of the required data for booting the main operating systems315in the dynamic partition348, the flow proceeds from step425to step435. At step435, check whether the processors complete the booting state synchronization or not. When the booting state synchronization is not completed yet, step435is repeated until the booting state synchronization is completed.

Next, at step440, check whether or not the required data for booting the main operating system315are available in the static backup table352or the dynamic prefetch table354. When the required data are available in the static backup table352or the dynamic prefetch table354, the flow proceeds to step445to read the required data for booting the main operating system315from the static backup table352or the dynamic prefetch table354. Otherwise, the flow proceeds to step450to read the required data from the static partition346or the dynamic partition348for booting the main operating system315. Next, at step455, check whether the booting sequence of the main operating system315requires more data or not. When the booting sequence requires more data, the flow returns to step440. When the booting sequence does not require more data, the flow of the method of file system prefetching ends here.

In the booting sequence of an electronic device with multiple processors and multiple operating systems, the bottleneck is copying the required data from the non-volatile storage to the volatile storage. The method and the electronic device provided by the present invention can prefetch the required data in the time waiting for the booting state synchronization to shorten the booting time of the electronic device. In some embodiments of the present invention, the method and the electronic device provided by the present invention can reduce 5%-60% of the time of copying the required data from the non-volatile storage to the volatile storage.