WO2023001208A1 - 多文件同步方法及电子设备 - Google Patents

多文件同步方法及电子设备 Download PDF

Info

Publication number
WO2023001208A1
WO2023001208A1 PCT/CN2022/106900 CN2022106900W WO2023001208A1 WO 2023001208 A1 WO2023001208 A1 WO 2023001208A1 CN 2022106900 W CN2022106900 W CN 2022106900W WO 2023001208 A1 WO2023001208 A1 WO 2023001208A1
Authority
WO
WIPO (PCT)
Prior art keywords
synchronization
file
file copy
data
copy
Prior art date
Application number
PCT/CN2022/106900
Other languages
English (en)
French (fr)
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 华为技术有限公司
Publication of WO2023001208A1 publication Critical patent/WO2023001208A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F15/00Digital computers in general; Data processing equipment in general
    • G06F15/16Combinations of two or more digital computers each having at least an arithmetic unit, a program unit and a register, e.g. for a simultaneous processing of several programs
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/17Details of further file system functions
    • G06F16/178Techniques for file synchronisation in file systems
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1095Replication or mirroring of data, e.g. scheduling or transport for data synchronisation between network nodes

Definitions

  • the present application relates to the field of electronic technology, in particular to a multi-file synchronization method and electronic equipment.
  • AIoT artificial intelligence&internet of things
  • the client When the server shares one or more files to the client, the client stores the one or more shared files in a local cache.
  • the client needs to synchronize the modified shared file to the server. For example, a user shares a document file on a mobile phone to a computer for modification, and at this time, the computer needs to continuously synchronize the document file modified by the user to the mobile phone.
  • the client can perform synchronization immediately after the user modifies the shared file each time; or, the client can perform synchronization after accumulating a certain amount of synchronization data locally.
  • Embodiments of the present application provide a method for synchronizing multiple files and an electronic device.
  • the multi-file synchronization method provided by the present application determines the synchronization priority of the files based on the aging degree of the files and the data volume of the synchronization data, and then determines the synchronization order of the files based on the synchronization priorities.
  • the client implements this method to synchronize multiple files, it can not only ensure that the client does not prioritize the synchronization of files with a lower aging degree, but also reduce the average synchronization time of multiple files.
  • the present application provides a multi-file synchronization method, the method comprising:
  • the client obtains multiple file copies from the server; the client determines the synchronization information of the multiple file copies, the synchronization information includes the data volume and aging degree of the synchronization data, and the aging degree corresponds to the unsynchronized duration of the file copy; The client determines the synchronization priority of the multiple file copies based on the synchronization information of the multiple file copies and a first preset condition; the first preset condition includes: when the aging degree of the file copy is within the first range , the synchronization priority of the file copy is related to the aging degree of the file copy; when the aging degree of the file copy is in the second range, the synchronization priority of the file copy is related to the data volume of the synchronization data of the file copy .
  • the client may determine the synchronization priority of the file copy according to the aging degree of the file and the data volume of the synchronization data. First of all, if the synchronization priority of the file copy is determined only based on the amount of synchronization data of the file copy, then after the client's post-synchronization file is modified, the amount of synchronization data of the file will increase, which will lead to less priority. Synchronization; Secondly, if the synchronization is performed only based on the aging degree of the file copy, the average synchronization time of the client will be longer.
  • the client implements the multi-file synchronization method provided by this application, which can not only ensure that there will be no file copies on the client that are always high in priority and will not be synchronized, but also can reduce the average synchronization time of multiple file copies.
  • the client determines a first synchronization rate; the client determines a set of files to be synchronized based on the first synchronization rate and the priorities of the plurality of file copies; the client The terminal synchronizes the file copies in the file collection to be synchronized.
  • the client after the client determines the synchronization priority of multiple file copies, it can predict the synchronization rate, and then determine the set of files to be synchronized, so as to prevent the client from backlogging all the files to be synchronized in the protocol stack or In the cache of the protocol stack, the load of the protocol stack is reduced.
  • the client determines the historical synchronization rate, and the historical synchronization rate is related to the data volume of the synchronization data of the historical synchronization and the synchronization duration of the historical synchronization;
  • the synchronization rate determines the first synchronization rate.
  • the client can predict the first synchronization rate based on the historical synchronization rate.
  • the client determines the data volume of the synchronization data based on the first synchronization rate and the expected synchronization duration; the client determines the data volume of the synchronization data based on the data volume of the synchronization data and the plurality of files
  • the synchronization priority of the replica determines the set of files to be synchronized.
  • the client may determine the amount of data to be sent for this synchronization based on the first synchronization rate, and then determine the set of files to be synchronized based on the synchronization priorities of multiple file copies.
  • the synchronization data includes dirty data or write operations.
  • the client determines the synchronization information of multiple file copies based on the dirty bit of the page; or, the client determines the synchronization information of multiple file copies based on the write operation .
  • the client needs to traverse the cache to determine the synchronization information of multiple file copies based on the dirty bits; if the client determines the synchronization information of multiple file copies based on the write operation, the cache may not be traversed to reduce the amount of calculation.
  • the synchronization information further includes: at least one of the location of dirty pages, the number of dirty pages, the proportion of synchronized data to the file, the last modification time, and the latest synchronization time .
  • the client at least determines the synchronization priority of the file copy according to the aging degree and the amount of data to be synchronized, and may also determine the synchronization priority of the file copy according to other parameters in the synchronization information.
  • the lower limit of the first range is greater than or equal to the upper limit of the first range; the synchronization priority of the file copy in the first range is lower than that of the file copy in the second range The synchronization priority; the file copy with a lower synchronization priority will be synchronized first.
  • the file copies in the first range when the lower limit of the first range is greater than or equal to the upper limit of the second range, the file copies in the first range have a higher aging degree than the file copies in the second range, so a smaller synchronization is configured. Priority, so that the copy of the file that has not been synchronized for a long time can be synchronized first.
  • the upper limit of the first range is smaller than the lower limit of the first range; the synchronization priority of the file copy in the first range is greater than that of the file copy in the second range Synchronization priority; the file copy with lower synchronization priority will be synchronized first.
  • the file copies in the first range are less aged than the file copies in the second range, so configure a larger synchronization Priority, so that the copy of the file that has not been synchronized for a long time can be synchronized first.
  • the multiple file copies include a first file copy and a second file copy; the aging degree of the first file copy is within the first range, and the first file copy The aging degree of the file copy is within the first range; when the aging degree of the first file copy is smaller than the aging degree of the second file copy, the synchronization priority of the first file copy is greater than the synchronization priority of the second file copy; When the aging degree of the first file copy is greater than the aging degree of the second file copy, the priority of the first file copy is lower than the synchronization priority of the second file copy; the file copy with a lower synchronization priority will be prioritized Synchronize.
  • the synchronization sequence between the first file copy and the second file copy can be determined further according to the aging degree .
  • the aging degree of the first file copy when the aging degree of the first file copy is equal to the aging degree of the second file copy, and the amount of synchronization data of the first file copy is less than In the case of the amount of synchronization data of the second file copy, the synchronization priority of the first file copy is less than the synchronization priority of the second file copy; when the aging degree of the first file copy is equal to the second file copy In the case of aging degree, and when the data volume of the synchronization data of the first file copy is greater than the data volume of the synchronization data of the second file copy, the synchronization priority of the first file copy is higher than that of the second file copy priority.
  • the client when the aging degrees of the first file copy and the second file copy are within the first range, and the aging degrees of the first file copy and the second file copy are the same, the client will Determine the synchronization sequence between the first file copy and the second file copy, thereby reducing the average synchronization time of multiple file copies.
  • the synchronization priority of the first file copy is equal to that of the second file copy The synchronization priority of the replica.
  • the multiple file copies include a third file copy and a fourth file copy; the aging degree of the third file copy is within the second range, and the fourth file copy The aging degree of the file is in the second range; when the data volume of the synchronization data of the third file copy is less than the data volume of the synchronization data of the fourth file copy, the synchronization priority of the third file copy is lower than that of the fourth file copy The synchronization priority of the copy; when the data volume of the synchronization data of the third file copy is greater than the data volume of the synchronization data of the fourth file copy, the synchronization priority of the third file copy is greater than the synchronization of the fourth file copy Priority; the file copy with lower synchronization priority will be synchronized first.
  • the client when the aging degrees of the third file copy and the fourth file copy are within the second range, the client may preferentially synchronize files with a small amount of data to be synchronized, thereby reducing the average synchronization duration.
  • an embodiment of the present application provides an electronic device, which includes: one or more processors and a memory; the memory is coupled to the one or more processors, and the memory is used to store computer program codes,
  • the computer program code includes computer instructions, and the one or more processors call the computer instructions to make the electronic device execute the method described in the first aspect and any possible implementation manner of the first aspect.
  • the embodiment of the present application provides a chip system, the chip system is applied to an electronic device, and the chip system includes one or more processors, and the processor is used to invoke computer instructions so that the electronic device executes the first Aspect and the method described in any possible implementation manner of the first aspect.
  • the embodiment of the present application provides a computer program product containing instructions, when the above-mentioned computer program product is run on the electronic device, the electronic device is made to execute any of the possible implementations in the first aspect and the first aspect described method.
  • the embodiment of the present application provides a computer-readable storage medium, including instructions.
  • the electronic device can execute any possible implementation method according to the first aspect and the first aspect. described method.
  • the above-mentioned electronic device provided in the second aspect, the chip system provided in the third aspect, the computer program product provided in the fourth aspect, and the computer storage medium provided in the fifth aspect are all used to execute the method provided in the embodiment of the present application . Therefore, the beneficial effects that it can achieve can refer to the beneficial effects in the corresponding method, and will not be repeated here.
  • FIG. 1A is a schematic diagram of an example of a network file system involved in the present application.
  • FIG. 1B is an exemplary schematic diagram of the write-back mechanism involved in the present application.
  • FIG. 1C is an exemplary schematic diagram of the dependency graph in the write-back mechanism involved in the present application.
  • FIG. 1D is an exemplary schematic diagram of transactions in the write-back mechanism involved in the present application.
  • FIG. 1E is an exemplary schematic diagram of a write barrier in the write-back mechanism involved in the present application.
  • FIG. 1F is an exemplary schematic diagram of persistence (persist) in the write-back mechanism involved in the present application
  • FIG. 2A and FIG. 2B are an exemplary schematic diagram of a file write-back synchronization method involved in the present application
  • FIG. 2C and FIG. 2D are an exemplary schematic diagram of a scenario of implementing a file write-back synchronization method involved in the present application
  • FIG. 3 is an exemplary schematic diagram of a multi-file synchronization method provided by an embodiment of the present application
  • FIG. 4A and FIG. 4B are an exemplary schematic diagram of the communication connection between the client and the server provided by the embodiment of the present application;
  • FIG. 5 is an exemplary schematic diagram of a method for determining synchronization information provided by an embodiment of the present application
  • FIG. 6 is an exemplary schematic diagram of a method for determining the number of synchronized files provided by the embodiment of the present application.
  • FIG. 7 is an exemplary schematic diagram of a method for determining a synchronized file or dirty data of a file provided by an embodiment of the present application
  • FIG. 8 is an exemplary schematic diagram of a timeout mechanism provided by an embodiment of the present application.
  • FIG. 9A and FIG. 9B are an exemplary schematic diagram of a multi-file synchronization scenario provided by the embodiment of the present application.
  • FIG. 10 is an exemplary schematic diagram of a hardware structure of an electronic device 100 provided by an embodiment of the present application.
  • FIG. 11 is an exemplary schematic diagram of the software structure of the electronic device 100 provided by the embodiment of the present application.
  • FIG. 12 is a schematic diagram of another software architecture of the electronic device 100 provided by the embodiment of the present application.
  • first and second are used for descriptive purposes only, and cannot be understood as implying or implying relative importance or implicitly specifying the quantity of indicated technical features. Therefore, the features defined as “first” and “second” may explicitly or implicitly include one or more of these features. In the description of the embodiments of the present application, unless otherwise specified, the “multiple” The meaning is two or more.
  • the network file system (network file system, NFS) supports the client to access the source files on the server through the network in a manner similar to accessing local files.
  • NFS network file system
  • the client and the server need to be synchronized.
  • data consistency refers to that the copy of the source file cached on the client is the same as the data of the source file on the server.
  • synchronization is a behavior initiated by the client to achieve data consistency.
  • the object that the client performs the synchronous behavior can be dirty data, or can be the I/O operation (referred to as write operation) that the client modifies the copy of the source file in the cache.
  • the object of synchronization behavior is called synchronization data, and synchronization data can be dirty data or write operation.
  • dirty data refers to data that has been modified on the client but has not been synchronized to the server, that is, dirty data refers to data that is inconsistent between the copy of the source file on the client and the source file on the server.
  • the dirty data synchronization of the client can realize the data consistency of the final state; the synchronous write operation of the client can realize the data consistency of the intermediate state and the final state.
  • the final state refers to the state of the data after the synchronization is completed;
  • the intermediate state refers to the state of the data change process of the source file and the copy of the source file before the final state.
  • the following takes synchronizing data as a write operation as an example to introduce a method for synchronizing a single file.
  • FIG. 1A is a schematic diagram of an example of a network file system involved in this application.
  • the server can map the source file to the local client, and the client can operate the virtual file system through a system call (system call), and then operate the source file.
  • system call system call
  • the modification operation when the client modifies the source file on the server, the modification operation will be transferred to the server by Remote Procedure Call (RPC), and the server will complete the modification of the source file based on the modification operation, and then realize the client and service terminal synchronization.
  • RPC Remote Procedure Call
  • the source file is in a readable state before the service segment completes the modification of the source file based on the modification operation , cannot be modified by the client, and the user experience is poor.
  • the server can send some or all of the data of the shared file to the client.
  • the client will store part or all of the data of the shared file in the cache.
  • FIG. 1B is an exemplary schematic diagram of the write-back mechanism involved in the present application.
  • the client can store some or all of the data of the source file on the server in the local cache, and use queues or other data structures to organize all data pages related to the copy of the source file, without having to pass through RPC for network access reduces the overhead and delay of clients modifying copies of source files.
  • the write-back mechanism when the client modifies the copy of the source file, the write-back mechanism is triggered, and one or several modification operations can be divided into one or several write operations, and the one or several write operations are sent to the server .
  • the server may temporarily not process the one or several write operations, and send a response to the client to inform the client that the server has received the one or several write operations.
  • the one or several write operations can keep the copy of the source file cached on the client side consistent with the data of the source file on the server side, thereby achieving synchronization. That is, one synchronization of a single file includes the one or several write operations.
  • the client After the client receives this response, it can proceed to modify its copy of the source file. At a later point, the client can send a request to the server. After receiving the request, the server can complete the modification of the local source file based on one or several write operations received before. At this point, a synchronization between the client and the server is completed.
  • the data synchronized in the write-back mechanism may not be a write operation, but the dirty data of the copy of the source file.
  • a dependency graph can be established to ensure the data consistency of the intermediate state.
  • FIG. 1C is an exemplary schematic diagram of a dependency graph in the write-back mechanism involved in the present application.
  • each node in the dependency graph corresponds to a write operation and the data involved in the write operation.
  • the order of the arrows represents the sequential dependencies between different write operations, that is, the arrow points to data that must be synchronized before Ensure that the data pointing to this data is synchronized.
  • the value of x may be data corresponding to node No. 5
  • the value of y may be data corresponding to node No. 4.
  • the contents modified sequentially by the user on the client include: first modifying the value of y to 2, and secondly modifying the value of x to 1. After modification, the value of x on the client is 1, and the value of y is 6.
  • the client first synchronizes the modification operation of x, and then synchronizes the modification operation of y.
  • the data on the server includes: the value of x is 1, and the value of y is 1, which is not consistent with the data on the client. If, according to the dependency graph, the modification operation of y is synchronized first, and then the modification operation of x is synchronized, then the data on the server is consistent with the data on the client.
  • a group of write operations with dependencies can be synchronized as an inseparable transaction.
  • a transaction is the smallest unit of indivisible synchronization.
  • the synchronization of the transaction can be completed through commit, and stored in the log (journal) in the memory.
  • FIG. 1D is an exemplary schematic diagram of transactions in the write-back mechanism involved in the present application.
  • FIG. 1E is an exemplary schematic diagram of a write barrier in the write-back mechanism involved in the present application.
  • each flush instruction may be called a write barrier (write barrier).
  • the order of write operations within one epoc can vary; write operations within different epocs are relatively ordered. For example, the order of write operation 1 and write operation 2 can be changed, but write operation 1 must precede write operation 3.
  • the client can also store the copy of the source file in the cache, the location of the copy of the source file in the cache, and the location of the source file in the server in non-volatile memory such as ROM/flashmemory. in the storage medium.
  • FIG. 1F is an exemplary schematic diagram of persist in the write-back mechanism involved in the present application.
  • the client can save the copy of the modification operation in a non-volatile storage medium.
  • the client's copy of the source file includes data A, wherein the value of data A has not been synchronized after being modified by the client.
  • the client can save the write operation of modifying data A, the location of data A in the client cache, and the location of data A in the server in the non-volatile storage medium.
  • the client can obtain a copy of the source file from the server again, and restore the modification operation of the client from the non-volatile storage medium, thereby restoring the state of the copy of the source file on the client before power failure .
  • FIGS. 1A to 1F mainly introduce the content of the write-back mechanism when synchronizing a single file.
  • the following describes a file synchronization method involved in this application and the problems faced by this method when synchronizing multiple files.
  • a method for synchronizing files involved in the present application will be exemplarily introduced below with reference to the contents shown in FIG. 2A and FIG. 2B .
  • FIG. 2A and FIG. 2B are exemplary schematic diagrams of a file writeback synchronization method involved in the present application.
  • the server can share multiple source files, including file 1 and file 2, with the client through the network.
  • the client After the client receives the copy of the source file sent by the server, it may store part or all of the data of the copy of the source file in the local cache of the client.
  • dirty data of file 1 is generated.
  • the electronic device will store the dirty data in the cache of the electronic device, and if the cache is full, some dirty data needs to be eliminated.
  • the dirty data to be eliminated is the dirty data of file 2
  • other part or all of the dirty data of file 2 may be synchronized together, and the dirty data that has been successfully synchronized may be deleted after the synchronization is successful.
  • the dirty data to be eliminated is the dirty data of file 1
  • other old dirty data of file 1 may be synchronized together.
  • the network transmission rate between the client and the server is low when synchronizing the dirty data of file 1, or if the dirty data of file 1 has a large amount of data, it will cause network congestion and reduce the speed of other subsequent files.
  • the synchronization time of the file will affect the subsequent synchronization of other files.
  • FIG. 2C and FIG. 2D are exemplary schematic diagrams of a scenario of implementing a file write-back synchronization method involved in the present application.
  • the time spent is synchronization duration 1; when the client starts synchronization at synchronization time 3, it is completed at synchronization time 4
  • the synchronization takes a duration of 2.
  • synchronization duration 1 is shorter than synchronization duration 2 .
  • the client often needs to synchronize multiple files to the server.
  • the file write-back synchronization method involved in the present application may preferentially synchronize the files swapped out of the cache by the client, or randomly select files or dirty data of the files for priority synchronization.
  • the cache time of the file is longer, which increases the synchronization time of other subsequent files.
  • the client starts synchronizing file 1, file 2, and file 3 to the server at second 0.
  • the data volume of dirty data in file 1 is 1020kb
  • the data volume of dirty data in file 2 is 500kb
  • the data volume of dirty data in file 3 is 460kb
  • the network transmission rate between the client and server is 200kb/ s.
  • the client sends all the dirty data of file 1 to complete the synchronization of file 1.
  • file 2 when file 2 needs to be synchronized before 5.1s, it is necessary to wait for file 1 to be synchronized before starting data transmission. For example, at 0s, the client starts to synchronize file 1, but at 5.1s, it starts to transmit the dirty data of file 2, and at 7.6s, the client sends all the dirty data of file 2, and completes Synchronization of file 2.
  • file 3 when the file needs to be synchronized before 7.6s, it is necessary to wait for file 1 and file 2 to be synchronized before starting data transmission. For example, at 0s, the client starts to synchronize file 3, but at 7.6s, it starts to transmit the dirty data of file 3, at 9.9s, the client sends all the dirty data of file 3, and the Synchronization of file 2.
  • the synchronized files are random, which results in a longer synchronization time for the post-synchronized files. Further, if the data volume of the synchronization data is large when the network transmission rate is low, the synchronization duration of subsequent other files will be greatly increased.
  • an embodiment of the present application provides a multi-file synchronization method.
  • the multi-file synchronization method provided by the embodiment of the present application includes: first, the client will predict the synchronization rate at the current moment based on the historical synchronization rate; secondly, the client will determine each The priority of the synchronization file; finally, based on the priority of the synchronization file, the set of files to be synchronized is determined and synchronized.
  • a file refers to a copy of the source file on the client.
  • FIG. 3 is an exemplary schematic diagram of a multi-file synchronization method provided by an embodiment of the present application.
  • the multi-file synchronization method includes:
  • S301 The server establishes a communication connection with the client.
  • the client establishes a communication connection with the server.
  • the server is an electronic device that provides shared files to the client
  • the client is an electronic device that receives the shared files from the server.
  • the client/server can be a terminal device, such as a mobile phone, a tablet computer, a virtual reality terminal device, an augmented reality terminal device, a wireless terminal in industrial control, a wireless terminal in unmanned driving, a wireless terminal in telemedicine, Wireless terminals in smart grids, wireless terminals in transportation safety, wireless terminals in smart cities, wireless terminals in smart homes, wearable devices, vehicle-mounted devices, etc.
  • a terminal device such as a mobile phone, a tablet computer, a virtual reality terminal device, an augmented reality terminal device, a wireless terminal in industrial control, a wireless terminal in unmanned driving, a wireless terminal in telemedicine, Wireless terminals in smart grids, wireless terminals in transportation safety, wireless terminals in smart cities, wireless terminals in smart homes, wearable devices, vehicle-mounted devices, etc.
  • the server may serve the client, and the server may provide source files to the client and save client data, etc., and the server may also be called a server.
  • the client may be an endpoint that initiates a communication connection, or an endpoint that receives a communication connection.
  • the type of the communication connection established between the client and the server depends on the capabilities of the protocol stacks on the client and the server.
  • the protocol stacks on both the client and the server support multipath transmission protocols such as MPTCP, multipath quick udp internet connection (MPQUIC), etc.
  • MPTCP multipath transmission protocols
  • MPQUIC multipath quick udp internet connection
  • FIG. 4A and FIG. 4B are exemplary schematic diagrams of a communication connection between a client and a server provided by an embodiment of the present application.
  • the client may be a mobile terminal, such as a mobile phone.
  • the mobile phone communicates with the server through the base station and the router at the same time.
  • the IP address allocated by the base station to the mobile phone is IP1
  • the IP address allocated by the router to the mobile phone is IP2
  • the source port on the mobile phone is 80
  • the IP address of the server is IP3, and the target port on the server is 1314.
  • the mobile phone can communicate with the server through the first physical path: (IP1, 80, IP3, 1314) and the second physical path: (IP2, 80, IP3, 1314).
  • the client may also establish a communication connection with the server through the near-field communication service.
  • the near-field communication service may include: Bluetooth, Apple Wireless Direct Link (AWDL), HiLink, ZigBee, and the like.
  • the client may be a PC
  • the server may be a mobile phone.
  • the mobile phone establishes a connection with the PC through Bluetooth and a router respectively.
  • the client and the server can establish communication connections in many different ways.
  • S302 The server shares the source file with the client.
  • the server sends a copy of the source file to the client to share the source file.
  • the server may share the source file with the client in response to the request of the client, or the server may share the source file with the client automatically after establishing a communication link.
  • S303 The client stores the obtained copy of the source file in the cache.
  • the client after the client receives the copy of the source file from the server, it can store all the data of the copy of the source file in the cache, such as in the page cache (pagebuffer) of RAM, or other random access storage media, in non-volatile storage media.
  • the client after the client receives the copy of the source file from the server, it can store part of the data of the copy of the source file in the cache, and the remaining part can be stored in a non-volatile storage medium on the client, such as ROM/ in flash memory.
  • the partial data of the copy of the source file may be the data of the copy of the source file which is often modified by the client.
  • the client when it modifies the source file, it may determine/update the synchronization information of the copy of the source file.
  • the synchronization information includes: the location of dirty pages, the number of dirty pages, whether the file is dirty, the proportion of dirty data to file data, the latest modification time, the latest synchronization time, the amount of data written, etc.
  • the client can determine the modified file and the modified data based on the write operation. Alternatively, the client may determine whether the page is a dirty page (dirtypage) according to the dirtybit identifier of the page, and a dirty page is dirty data.
  • a dirty page dirty data
  • the write operation may include: the file to be written, the page to be modified in the file to be written, and the data to be modified.
  • the format of the write operation can be write(file,buf,&pos).
  • the input parameters of the write operation may include the file file, the modified data buf and the position &pos of the modified data.
  • the data position &pos can determine the modified page.
  • the method for determining synchronization information will be exemplarily introduced below in combination with the contents shown in FIG. 5 and Table 1.
  • FIG. 5 is an exemplary schematic diagram of a method for determining synchronization information provided by an embodiment of the present application.
  • the modified file and the location of the modified data on the page of the file can be determined through the write operation.
  • Table 1 is an exemplary schematic table of file dirty data statistics provided by the embodiment of the present application.
  • the copies of the source files in the client's cache include: file 1 , file 2 and file 3 .
  • file 1 includes 2 dirty pages, the amount of dirty data is 8KB, the proportion of dirty data is 28.57%, the latest modification time is T1, and the latest synchronization time is T2;
  • file 2 includes 4 dirty pages, the amount of dirty data is 16KB, and the dirty data
  • the ratio is 50%, the latest modification time is T3, and the latest synchronization time is T4;
  • file 3 includes 1 dirty page, the amount of dirty data is 4KB, the dirty data ratio is 20%, the latest modification time is T5, and the latest synchronization time is T6.
  • the client can also traverse the dirtybit identifiers of the pages in the cache to determine the dirty pages of each file.
  • the client when modifying the copy of the source file, the client can determine the synchronization information of the copy of the source file based on the modification operation.
  • S305 The client determines synchronization priorities of multiple files based on the synchronization information.
  • the client may determine synchronization priorities of multiple files based on the synchronization information in multiple ways. Wherein, the client may select different methods to determine the synchronization priority of the file based on different criteria.
  • the client can, based on parameters such as the ratio of the amount of synchronized data to the copy of the source file, the frequency of file modification, and the latest synchronization time, etc., before determining the synchronization priority of the file, the files that need to be synchronized on the client to group.
  • the synchronization sequence between groups can be determined according to the user's choice or the preset rules of the client, and the file synchronization sequence in the group is determined by the file synchronization priority in the group.
  • group by last modification time The files modified within 10s are divided into the first group, the files modified within 10s-20s are divided into the second group, the files modified within 20s-30 are divided into the third group, etc.
  • the synchronization priority of the files in each group can determine the synchronization priority of the files in the group in the following manner. For another example, group according to the modification frequency, the files modified 0-5 times within 10s are divided into the first group, the files modified 6-10 times within 10s are classified into the second group, and the files modified 11-15 times within 10s The files are divided into a third group and so on.
  • the grouping of files may be determined based on multiple parameters.
  • the client can determine the synchronization priority of multiple files according to the aging degree.
  • the client can determine the age of the copy of the source file in the cache, where the age can be related to the last synchronization time of the file.
  • Age degree (T now -T rec )k1
  • Age degree is the aging degree of the copy of the source file
  • T now is the present moment
  • T rec is the latest synchronization moment of the copy of the source file
  • k1 is the aging coefficient 1
  • (T now -T rec ) is the unsynchronized duration of the copy of the source file.
  • the aging coefficients of different files may be different.
  • the aging factor may be higher for files that are frequently modified by users and files used by multiple users.
  • T 1 is a preset aging time threshold 1.
  • T 2 is the preset aging time threshold 1.
  • k2 is aging coefficient 2.
  • the client After the client determines how old the copy of the source file in the cache is, it can determine the synchronization priority for that file.
  • a file's sync priority equals a negative age.
  • the smaller the file synchronization priority value the higher the priority to be synchronized.
  • the client may determine the synchronization sequence in the multiple files based on the data volume of the synchronization data. For example, a file with a small amount of data to be synchronized among multiple files will be synchronized preferentially.
  • prioritizing the synchronization of files with a high degree of aging can prevent the client from always synchronizing files with newly generated synchronization data and always ignoring files that have been modified before synchronization, thereby causing the aging of the files with the largest degree of aging on the client
  • the degree is low, which in turn helps to keep the data gap between the client and the server within a small range.
  • the client can determine the synchronization priority of multiple files according to the data volume of the synchronization data or the ratio of the data volume of the synchronization data to the copy of the source file.
  • the client can determine the data volume of the synchronization data of the copy of the source file, and then determine the synchronization priority of multiple files.
  • the file synchronization priority is equal to negative, the data volume of the file synchronization data is negative, or if the file synchronization priority is negative, the data volume of the file synchronization data accounts for the ratio of the copy of the source file.
  • the synchronization priority of the file is equal to the negative dirty data amount or negative dirty data ratio*100 of the copy of the source file.
  • the synchronization priority of the file is equal to the data volume of the negative write operation of the copy of the source file or the ratio of the data volume of the synchronization data to the copy of the source file*100.
  • the client determines the synchronization priority of multiple files according to the data volume of the synchronization data or the ratio of the data volume of the synchronization data to the copy of the source file
  • the file with a large amount of synchronization data will be synchronized first or the file with a large amount of synchronization data will be synchronized first.
  • the client may preferentially synchronize files with a large amount of synchronized data, thereby improving user experience.
  • synchronizing data when synchronizing data is dirty data, it is more robust to determine the priority of synchronizing files by using the data volume of the synchronous data rather than the modification frequency of the file.
  • the user modifies the variable Z of file 1 to 1, 3, 5, and 1.
  • the data size of the synchronization data of file 1 is 0, and file 1 does not need to be synchronized, or file 1 does not need to be synchronized first .
  • the priority of the synchronization file is determined according to the modification frequency of the file, and the file 1 will be synchronized first.
  • the client can determine the synchronization priority of multiple files according to the data volume and aging degree of the synchronization data.
  • T 2 is a preset aging time threshold 2.
  • the synchronization coefficient may be related to the type of data volume of the synchronization data, that is, the synchronization coefficient when the synchronization data is dirty data is different from the synchronization coefficient when the synchronization data is a write operation. For example, when the synchronization data of the copy of file 1 is dirty data, the synchronization factor of the copy of file 1 is 1; when the synchronization data of the copy of file 2 is a write operation, the synchronization factor is 0.9. Or, when the synchronization data of the file 2 copy is a write operation, the synchronization factor is 1.1.
  • the client can determine the synchronization sequence in the multiple files based on the aging degree.
  • T 3 is a preset aging time threshold 3.
  • T 4 is a preset aging time threshold 4.
  • the client can also determine the synchronization priority of the file in various ways, which is not limited here.
  • the file synchronization priority provided by the embodiment of the present application will make the synchronization data with small priority be higher, and then synchronize first.
  • the file with the aging degree lower than the threshold is preferentially synchronized, thereby avoiding the client always giving priority to synchronizing the newly generated synchronization data and delaying the synchronization caused by the file with a higher aging degree
  • the inconsistency between the client and the data segment improves the user experience.
  • the method for determining the synchronization priority of the file is related to the way the client synchronizes the file. For example, when the client synchronizes dirty data, in most cases, the smaller the amount of dirty data in a file, the higher the priority. For another example, when the client performs synchronous write operations, in most cases, the smaller the amount of file write operations, the higher the priority.
  • the client may determine synchronization priorities for multiple files according to the data volume and/or aging degree of the synchronization data.
  • T5 is the preset aging time threshold 5 .
  • T 6 is a preset aging time threshold 6, wherein F (data volume of synchronization data, Age degree ) is a preset function, and the output is the synchronization priority of the file.
  • T7 is the preset aging time threshold 7
  • T8 is the preset aging time threshold 8 .
  • S306 The client determines a set of files to be synchronized based on the synchronization priority and the synchronization rate of the files.
  • the client predicts the current synchronization rate based on the synchronization rate in one or more time slices in the past. Based on the synchronization rate, the client can determine the data volume of the synchronization data for one synchronization, and then determine the set of files to be synchronized based on the data volume of the synchronization data and the synchronization priority of the files.
  • the synchronization rate may be the transmission rate of the synchronization data between the client and the server, or may be the rate at which the client sends the synchronization data, or may be the rate at which the server receives the synchronization data.
  • the communication connection between the client and the server may be graded based on the synchronization rate, and then the amount of synchronous data to be synchronized is determined according to the level of the communication connection.
  • Table 2 is an exemplary schematic table of the communication connection classification provided by the embodiment of the present application.
  • the client can determine the level of the communication connection based on the synchronization rate, and determine the amount of synchronization data for one synchronization.
  • the expected synchronization duration may be a fixed value, or the expected synchronization duration may be related to the level of the communication connection, or the expected synchronization duration may be related to the type of the synchronized file.
  • the higher the level of the communication connection (the smaller the value), the lower the desired synchronization duration may be.
  • the expected synchronization duration of files modified by the user frequently may be lower than the expected synchronization duration of files modified by the user infrequently.
  • the amount of synchronization data may be directly determined according to the level of the communication connection. For example, when the communication connection is level 1, the client can directly determine that the data volume of the synchronization data is 50KB, and when the communication connection is level 2, the client can directly determine that the data volume of the synchronization data is 45KB, etc.
  • the method for the client to determine the set of files to be synchronized will be exemplarily introduced below with reference to the content shown in FIG. 6 .
  • FIG. 6 is an exemplary schematic diagram of a method for determining the number of synchronized files provided by the embodiment of the present application.
  • the method for determining the number of synchronized files may include:
  • S601 The client initializes the synchronization queue.
  • the client has determined the synchronization priorities of different files.
  • the client can initialize the synchronization queue through a variety of data structures such as queues, arrays, and minimum heaps. Among them, files with high priority can be determined first by the client.
  • the client determines the data volume of the synchronization data for one synchronization.
  • the client may determine the data size of the synchronization data for one synchronization.
  • S603 The client adds the file with the highest synchronization priority to the file collection to be synchronized.
  • the client sequentially extracts the files with the highest priority from the synchronization queue, adds the file with the highest priority to the file collection to be synchronized, and updates the synchronization queue.
  • S604 The sum of the data volumes of the synchronization data of the files in the file set to be synchronized is less than or equal to the data volume of the synchronization data for one synchronization.
  • the client judges whether the sum of the dirty data of the files to be synchronized is smaller than the data volume of the synchronized data in one synchronization. If yes, execute step S603; if not, execute step S605.
  • the client will judge whether the sum of the write operations of the files to be synchronized is less than the data volume of the synchronization data.
  • the client when the sum of the synchronization data in the file collection to be synchronized is greater than the data volume of the synchronization data in one synchronization, the client removes the last added file from the file collection to be synchronized.
  • the client may not remove the last added file from the file collection to be synchronized.
  • the method for determining the set of files to be synchronized in FIG. 6 will be specifically and exemplarily introduced below in conjunction with the content shown in FIG. 7 .
  • FIG. 7 is an exemplary schematic diagram of a method for determining a set of files to be synchronized provided by an embodiment of the present application.
  • the client can use the minimum heap to determine the set of files to be synchronized, and the value of each heap node in the minimum heap is the synchronization priority of different files.
  • the client can continuously select the root node at the top of the smallest heap until the data volume of the file collection to be synchronized is greater than the amount of synchronized data for one synchronization.
  • the client can continuously select the synchronization data of the file corresponding to the root node at the top of the smallest heap for synchronization until the synchronization data of the file to be synchronized is added next time, and the sum of the collection data of the files to be synchronized is greater than the synchronization data of one synchronization for the first time amount of data.
  • the client determines that the data volume of the synchronization data for one synchronization is 45KB.
  • the data volume of the synchronization data of the file whose synchronization priority is -5 is 15KB
  • the data volume of the synchronization data of the file whose synchronization priority is -2 is 28KB
  • the data volume of the synchronization data of the file whose synchronization priority is 12 is 30KB
  • the synchronization data volume of the file whose synchronization priority is 16 is 35KB.
  • the client can select file 1 with a synchronization priority of -5, file 2 with a synchronization priority of -2, and file with a synchronization priority of -28 as file 3 for this synchronization, namely file 1, file 2.
  • File 3 constitutes a collection of files to be synchronized; or, the client can select file 1 with a synchronization priority of -5 and a file with a synchronization priority of -2 as file 2 for this synchronization, that is, file 1 and file 2 constitute A collection of files to be synchronized.
  • the client After the client determines the file set to be synchronized, it can send the synchronization data of the files in the file set to be synchronized to the server in order of synchronization priority.
  • the client can periodically synchronize with the server.
  • the synchronization period may be a pre-configured fixed threshold, or the synchronization period may be changed according to the synchronization rate and the level of the communication connection determined by the client in step S306. For example, when the synchronization rate is high or when the level of the communication connection is high, the synchronization cycle can be reduced and the frequency of synchronization can be increased. For example, when the level of communication connection is 1, the synchronization period is 0.02s; when the level of communication connection is 2-4, the synchronization period is 0.1s; when the level of communication connection is 5-7, the synchronization period is 0.3s.
  • the client can perform synchronization after the amount of data in the cache occupies a certain proportion of the cache. For example, a client syncs when a copy of the source file occupies 80% of the cache.
  • the synchronization of a single file may be a write-back mechanism.
  • the write-back mechanism For the content of the write-back mechanism, reference may be made to the corresponding text descriptions in FIG. 1B , FIG. 1C , FIG. 1D , FIG. 1E , and FIG. 1F , and will not be repeated here.
  • the client may also be configured with a timeout mechanism to cope with network jitter. For example, if the synchronization duration exceeds the preset threshold, the synchronization is suspended, and a heartbeat detection packet is sent to test the data transmission rate of the communication connection between the client and the server.
  • FIG. 8 is an exemplary schematic diagram of a timeout mechanism provided by an embodiment of the present application.
  • the client When the client is in the synchronization process, based on the protocol followed by the communication connection between the client and the server, the client can determine the synchronization duration. For example, if the communication connection between the client and the server complies with the TCP protocol, the client sends an IP message carrying the dirty data of the file, and then determines the synchronization duration according to the time difference between the client receiving the ACK message from the server.
  • the client suspends synchronization, that is, suspends sending data to the server, and sends a heartbeat detection packet to the server.
  • heartbeat detection may also be referred to as disconnection detection. If the client determines that the communication connection is restored, the synchronization is continued; if the communication connection is not restored, the heartbeat detection packet is resent.
  • the multi-file synchronization method provided by the embodiment of the present application can reduce the average synchronization duration of synchronization in the client cache.
  • N There are N copies of the source file in the cache on the client.
  • the synchronization durations of the synchronization data of the copies of the N source files are respectively M 1 , M 2 ,...,M N .
  • the synchronization priority of the file is determined based on the data volume of the file synchronization data, the more the data volume of the file synchronization data, the lower the file synchronization priority.
  • the client determines the synchronization sequence of the files according to the determined synchronization priority of the files: file N to file 1 .
  • the multi-file synchronization method does not give priority to synchronizing files with low aging degree, and avoids delaying synchronization aging caused by the client always giving priority to synchronizing newly generated synchronous data
  • the inconsistency between the client and the data segment caused by a high-level file improves the user experience.
  • the multi-file synchronization method provided by the embodiment of the present application can reduce the average synchronization duration of synchronization in the client cache by combining the content shown in FIG. 2D and FIG. 9A .
  • the data volume of the synchronization data of file 1 is 1020 KB
  • the data volume of the synchronization data of file 2 is 500 KB
  • the data volume of the synchronization data of file 3 is 460 KB.
  • the client may determine that file 1 has the lowest synchronization priority, file 2 has the second lowest synchronization priority, and file 3 has the synchronization priority, and then synchronizes file 3, file 2, and file 1 sequentially based on the determined synchronization priorities.
  • FIG. 9A and FIG. 9B are exemplary schematic diagrams of a multi-file synchronization scenario provided by the embodiment of the present application.
  • the client starts synchronizing file 1 , file 2 , and file 3 with the server at 0 second.
  • the client sends out all the synchronization data of file 3 at 2.3 seconds to complete the synchronization of file 3; the client starts to transmit the synchronization data of file 2 at 2.3 seconds, and at 4.8 seconds, the client sends the synchronization data of file 2 All are sent out to complete the synchronization of file 2; the client starts to transmit the synchronization data of file 2 at 4.8 seconds, and at 9.9 seconds, the client sends all the synchronization data of file 3 to complete the synchronization of file 3.
  • the multi-file synchronization method provided by the embodiment of the present application also takes aging into consideration.
  • the cache on the client stores file 1 , file 2 , file 3 , file 4 , file 5 and file 6 .
  • the data volume of the synchronous data of file 1 is 1020KB
  • the data volume of the synchronous data of file 2 is 500KB
  • the data volume of the synchronous data of file 3 is 460KB
  • the data volume of the synchronous data of file 4 is 860KB
  • the data volume of the synchronous data of file 5 is
  • the data volume is 350KB
  • the data volume of the synchronization data of file 6 is 860KB.
  • the client When the client implements the multi-file synchronization method of this application, it can be based on Determines the synchronization priority of files. where T3 is equal to 10 .
  • the priorities from low to high are respectively: file 1, file 5, file 3, file 2, file 6, and file 4.
  • file 6 and file 4 have the same amount of synchronization data, and the aging degree is lower than the aging threshold.
  • the client can first synchronize file 6 with a small amount of data, and then synchronize file 4 with a large amount of data.
  • synchronization priority of the file may also be determined according to other methods involved in step S305.
  • Both the client and the server may be the electronic device 100 hereinafter.
  • FIG. 10 is an exemplary schematic diagram of a hardware structure of an electronic device 100 provided by an embodiment of the present application.
  • the electronic device 100 may be a cell phone, a tablet computer, a desktop computer, a laptop computer, a handheld computer, a notebook computer, an ultra-mobile personal computer (UMPC), a netbook, as well as a cellular phone, a personal digital assistant (personal digital assistant) digital assistant (PDA), augmented reality (augmented reality, AR) device, virtual reality (virtual reality, VR) device, artificial intelligence (artificial intelligence, AI) device, wearable device, vehicle-mounted device, smart home device and/or
  • PDA personal digital assistant
  • augmented reality augmented reality, AR
  • VR virtual reality
  • AI artificial intelligence
  • wearable device wearable device
  • vehicle-mounted device smart home device
  • smart home device smart home device
  • smart home device smart home device
  • the embodiment of the present application does not specifically limit the specific type of the electronic equipment.
  • the electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (universal serial bus, USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, and an antenna 2 , mobile communication module 150, wireless communication module 160, audio module 170, speaker 170A, receiver 170B, microphone 170C, earphone jack 170D, sensor module 180, button 190, motor 191, indicator 192, camera 193, display screen 194, and A subscriber identification module (subscriber identification module, SIM) card interface 195 and the like.
  • SIM subscriber identification module
  • the sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, bone conduction sensor 180M, etc.
  • the structure illustrated in the embodiment of the present invention does not constitute a specific limitation on the electronic device 100 .
  • the electronic device 100 may include more or fewer components than shown in the figure, or combine certain components, or separate certain components, or arrange different components.
  • the illustrated components can be realized in hardware, software or a combination of software and hardware.
  • the processor 110 may include one or more processing units, for example: the processor 110 may include an application processor (application processor, AP), a modem processor, a graphics processing unit (graphics processing unit, GPU), an image signal processor (image signal processor, ISP), controller, video codec, digital signal processor (digital signal processor, DSP), baseband processor, and/or neural network processor (neural-network processing unit, NPU), etc. Wherein, different processing units may be independent devices, or may be integrated in one or more processors.
  • application processor application processor, AP
  • modem processor graphics processing unit
  • GPU graphics processing unit
  • image signal processor image signal processor
  • ISP image signal processor
  • controller video codec
  • digital signal processor digital signal processor
  • baseband processor baseband processor
  • neural network processor neural-network processing unit
  • the controller can generate an operation control signal according to the instruction opcode and timing signal, and complete the control of fetching and executing the instruction.
  • a memory may also be provided in the processor 110 for storing instructions and data.
  • the memory in processor 110 is a cache memory.
  • the memory may hold instructions or data that the processor 110 has just used or recycled. If the processor 110 needs to use the instruction or data again, it can be called directly from the memory. Repeated access is avoided, and the waiting time of the processor 110 is reduced, thus improving the efficiency of the system.
  • processor 110 may include one or more interfaces.
  • the interface may include an integrated circuit (inter-integrated circuit, I2C) interface, an integrated circuit built-in audio (inter-integrated circuit sound, I2S) interface, a pulse code modulation (pulse code modulation, PCM) interface, a universal asynchronous transmitter (universal asynchronous receiver/transmitter, UART) interface, mobile industry processor interface (mobile industry processor interface, MIPI), general-purpose input and output (general-purpose input/output, GPIO) interface, subscriber identity module (subscriber identity module, SIM) interface, and /or universal serial bus (universal serial bus, USB) interface, etc.
  • I2C integrated circuit
  • I2S integrated circuit built-in audio
  • PCM pulse code modulation
  • PCM pulse code modulation
  • UART universal asynchronous transmitter
  • MIPI mobile industry processor interface
  • GPIO general-purpose input and output
  • subscriber identity module subscriber identity module
  • SIM subscriber identity module
  • USB universal serial bus
  • the I2C interface is a bidirectional synchronous serial bus, including a serial data line (serial data line, SDA) and a serial clock line (derail clock line, SCL).
  • processor 110 may include multiple sets of I2C buses.
  • the processor 110 can be respectively coupled to the touch sensor 180K, the charger, the flashlight, the camera 193 and the like through different I2C bus interfaces.
  • the processor 110 may be coupled to the touch sensor 180K through the I2C interface, so that the processor 110 and the touch sensor 180K communicate through the I2C bus interface to realize the touch function of the electronic device 100 .
  • the I2S interface can be used for audio communication.
  • processor 110 may include multiple sets of I2S buses.
  • the processor 110 may be coupled to the audio module 170 through an I2S bus to implement communication between the processor 110 and the audio module 170 .
  • the audio module 170 can transmit audio signals to the wireless communication module 160 through the I2S interface, so as to realize the function of answering calls through the Bluetooth headset.
  • the PCM interface can also be used for audio communication, sampling, quantizing and encoding the analog signal.
  • the audio module 170 and the wireless communication module 160 may be coupled through a PCM bus interface.
  • the audio module 170 can also transmit audio signals to the wireless communication module 160 through the PCM interface, so as to realize the function of answering calls through the Bluetooth headset. Both the I2S interface and the PCM interface can be used for audio communication.
  • the UART interface is a universal serial data bus used for asynchronous communication.
  • the bus can be a bidirectional communication bus. It converts the data to be transmitted between serial communication and parallel communication.
  • a UART interface is generally used to connect the processor 110 and the wireless communication module 160 .
  • the processor 110 communicates with the Bluetooth module in the wireless communication module 160 through the UART interface to realize the Bluetooth function.
  • the audio module 170 can transmit audio signals to the wireless communication module 160 through the UART interface, so as to realize the function of playing music through the Bluetooth headset.
  • the MIPI interface can be used to connect the processor 110 with peripheral devices such as the display screen 194 and the camera 193 .
  • MIPI interface includes camera serial interface (camera serial interface, CSI), display serial interface (display serial interface, DSI), etc.
  • the processor 110 communicates with the camera 193 through the CSI interface to realize the shooting function of the electronic device 100 .
  • the processor 110 communicates with the display screen 194 through the DSI interface to realize the display function of the electronic device 100 .
  • the GPIO interface can be configured by software.
  • the GPIO interface can be configured as a control signal or as a data signal.
  • the GPIO interface can be used to connect the processor 110 with the camera 193 , the display screen 194 , the wireless communication module 160 , the audio module 170 , the sensor module 180 and so on.
  • the GPIO interface can also be configured as an I2C interface, I2S interface, UART interface, MIPI interface, etc.
  • the USB interface 130 is an interface conforming to the USB standard specification, specifically, it can be a Mini USB interface, a Micro USB interface, a USB Type C interface, and the like.
  • the USB interface 130 can be used to connect a charger to charge the electronic device 100 , and can also be used to transmit data between the electronic device 100 and peripheral devices. It can also be used to connect headphones and play audio through them. This interface can also be used to connect other electronic devices, such as AR devices.
  • the interface connection relationship between the modules shown in the embodiment of the present invention is only a schematic illustration, and does not constitute a structural limitation of the electronic device 100 .
  • the electronic device 100 may also adopt different interface connection manners in the foregoing embodiments, or a combination of multiple interface connection manners.
  • the charging management module 140 is configured to receive a charging input from a charger.
  • the charger may be a wireless charger or a wired charger.
  • the charging management module 140 can receive charging input from the wired charger through the USB interface 130 .
  • the charging management module 140 may receive a wireless charging input through a wireless charging coil of the electronic device 100 . While the charging management module 140 is charging the battery 142 , it can also provide power for electronic devices through the power management module 141 .
  • the power management module 141 is used for connecting the battery 142 , the charging management module 140 and the processor 110 .
  • the power management module 141 receives the input from the battery 142 and/or the charging management module 140 to provide power for the processor 110 , the internal memory 121 , the display screen 194 , the camera 193 , and the wireless communication module 160 .
  • the power management module 141 can also be used to monitor parameters such as battery capacity, battery cycle times, and battery health status (leakage, impedance).
  • the power management module 141 may also be disposed in the processor 110 .
  • the power management module 141 and the charging management module 140 may also be set in the same device.
  • the wireless communication function of the electronic device 100 can be realized by the antenna 1 , the antenna 2 , the mobile communication module 150 , the wireless communication module 160 , a modem processor, a baseband processor, and the like.
  • Antenna 1 and Antenna 2 are used to transmit and receive electromagnetic wave signals.
  • Each antenna in electronic device 100 may be used to cover single or multiple communication frequency bands. Different antennas can also be multiplexed to improve the utilization of the antennas.
  • Antenna 1 can be multiplexed as a diversity antenna of a wireless local area network.
  • the antenna may be used in conjunction with a tuning switch.
  • the mobile communication module 150 can provide wireless communication solutions including 2G/3G/4G/5G applied on the electronic device 100 .
  • the mobile communication module 150 may include at least one filter, switch, power amplifier, low noise amplifier (low noise amplifier, LNA) and the like.
  • the mobile communication module 150 can receive electromagnetic waves through the antenna 1, filter and amplify the received electromagnetic waves, and send them to the modem processor for demodulation.
  • the mobile communication module 150 can also amplify the signals modulated by the modem processor, and convert them into electromagnetic waves through the antenna 1 for radiation.
  • at least part of the functional modules of the mobile communication module 150 may be set in the processor 110 .
  • at least part of the functional modules of the mobile communication module 150 and at least part of the modules of the processor 110 may be set in the same device.
  • a modem processor may include a modulator and a demodulator.
  • the modulator is used for modulating the low-frequency baseband signal to be transmitted into a medium-high frequency signal.
  • the demodulator is used to demodulate the received electromagnetic wave signal into a low frequency baseband signal. Then the demodulator sends the demodulated low-frequency baseband signal to the baseband processor for processing.
  • the low-frequency baseband signal is passed to the application processor after being processed by the baseband processor.
  • the application processor outputs sound signals through audio equipment (not limited to speaker 170A, receiver 170B, etc.), or displays images or videos through display screen 194 .
  • the modem processor may be a stand-alone device.
  • the modem processor may be independent from the processor 110, and be set in the same device as the mobile communication module 150 or other functional modules.
  • the wireless communication module 160 can provide wireless local area networks (wireless local area networks, WLAN) (such as wireless fidelity (Wireless Fidelity, Wi-Fi) network), bluetooth (bluetooth, BT), global navigation satellite, etc. applied on the electronic device 100.
  • System global navigation satellite system, GNSS
  • frequency modulation frequency modulation, FM
  • near field communication technology near field communication, NFC
  • infrared technology infrared, IR
  • the wireless communication module 160 may be one or more devices integrating at least one communication processing module.
  • the wireless communication module 160 receives electromagnetic waves via the antenna 2 , frequency-modulates and filters the electromagnetic wave signals, and sends the processed signals to the processor 110 .
  • the wireless communication module 160 can also receive the signal to be sent from the processor 110 , frequency-modulate it, amplify it, and convert it into electromagnetic waves through the antenna 2 for radiation.
  • the antenna 1 of the electronic device 100 is coupled to the mobile communication module 150, and the antenna 2 is coupled to the wireless communication module 160, so that the electronic device 100 can communicate with the network and other devices through wireless communication technology.
  • the wireless communication technology may include global system for mobile communications (GSM), general packet radio service (general packet radio service, GPRS), code division multiple access (code division multiple access, CDMA), broadband Code division multiple access (wideband code division multiple access, WCDMA), time division code division multiple access (time-division code division multiple access, TD-SCDMA), long term evolution (long term evolution, LTE), BT, GNSS, WLAN, NFC , FM, and/or IR techniques, etc.
  • GSM global system for mobile communications
  • GPRS general packet radio service
  • code division multiple access code division multiple access
  • CDMA broadband Code division multiple access
  • WCDMA wideband code division multiple access
  • time division code division multiple access time-division code division multiple access
  • TD-SCDMA time-division code division multiple access
  • the GNSS may include a global positioning system (global positioning system, GPS), a global navigation satellite system (global navigation satellite system, GLONASS), a Beidou navigation satellite system (beidou navigation satellite system, BDS), a quasi-zenith satellite system (quasi -zenith satellite system (QZSS) and/or satellite based augmentation systems (SBAS).
  • GPS global positioning system
  • GLONASS global navigation satellite system
  • Beidou navigation satellite system beidou navigation satellite system
  • BDS Beidou navigation satellite system
  • QZSS quasi-zenith satellite system
  • SBAS satellite based augmentation systems
  • the electronic device 100 realizes the display function through the GPU, the display screen 194 , and the application processor.
  • the GPU is a microprocessor for image processing, and is connected to the display screen 194 and the application processor. GPUs are used to perform mathematical and geometric calculations for graphics rendering.
  • Processor 110 may include one or more GPUs that execute program instructions to generate or change display information.
  • the display screen 194 is used to display images, videos and the like.
  • the display screen 194 includes a display panel.
  • the display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active matrix organic light emitting diode or an active matrix organic light emitting diode (active-matrix organic light emitting diode, AMOLED), flexible light-emitting diode (flex light-emitting diode, FLED), Miniled, MicroLed, Micro-oLed, quantum dot light emitting diodes (quantum dot light emitting diodes, QLED), etc.
  • the electronic device 100 may include 1 or N display screens 194 , where N is a positive integer greater than 1.
  • the electronic device 100 can realize the shooting function through the ISP, the camera 193 , the video codec, the GPU, the display screen 194 and the application processor.
  • the ISP is used for processing the data fed back by the camera 193 .
  • the light is transmitted to the photosensitive element of the camera through the lens, and the light signal is converted into an electrical signal, and the photosensitive element of the camera transmits the electrical signal to the ISP for processing, and converts it into an image visible to the naked eye.
  • ISP can also perform algorithm optimization on image noise, brightness, and skin color.
  • ISP can also optimize the exposure, color temperature and other parameters of the shooting scene.
  • the ISP may be located in the camera 193 .
  • Camera 193 is used to capture still images or video.
  • the object generates an optical image through the lens and projects it to the photosensitive element.
  • the photosensitive element may be a charge coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor.
  • CMOS complementary metal-oxide-semiconductor
  • the photosensitive element converts the light signal into an electrical signal, and then transmits the electrical signal to the ISP to convert it into a digital image signal.
  • the ISP outputs the digital image signal to the DSP for processing.
  • DSP converts digital image signals into standard RGB, YUV and other image signals.
  • the electronic device 100 may include 1 or N cameras 193 , where N is a positive integer greater than 1.
  • Digital signal processors are used to process digital signals. In addition to digital image signals, they can also process other digital signals. For example, when the electronic device 100 selects a frequency point, the digital signal processor is used to perform Fourier transform on the energy of the frequency point.
  • Video codecs are used to compress or decompress digital video.
  • Electronic device 100 may support one or more video codecs.
  • the electronic device 100 can play or record videos in various encoding formats, for example: moving picture experts group (moving picture experts group, MPEG) 1, MPEG2, MPEG3, MPEG4 and so on.
  • MPEG moving picture experts group
  • the NPU is a neural-network (NN) computing processor.
  • NN neural-network
  • Applications such as intelligent cognition of the electronic device 100 can be realized through the NPU, such as image recognition, face recognition, speech recognition, text understanding, and the like.
  • the internal memory 121 may include one or more random access memories (random access memory, RAM) and one or more non-volatile memories (non-volatile memory, NVM).
  • RAM random access memory
  • NVM non-volatile memory
  • Random access memory can include static random-access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (synchronous dynamic random access memory, SDRAM), double data rate synchronous Dynamic random access memory (double data rate synchronous dynamic random access memory, DDR SDRAM, such as the fifth generation DDR SDRAM is generally called DDR5SDRAM), etc.;
  • SRAM static random-access memory
  • DRAM dynamic random access memory
  • SDRAM synchronous dynamic random access memory
  • SDRAM synchronous dynamic random access memory
  • double data rate synchronous Dynamic random access memory double data rate synchronous dynamic random access memory
  • DDR SDRAM double data rate synchronous dynamic random access memory
  • DDR SDRAM double data rate synchronous dynamic random access memory
  • DDR5SDRAM double data rate synchronous dynamic random access memory
  • the cache of the client may be located in random access memory.
  • Non-volatile memory may include magnetic disk storage devices, flash memory (flash memory).
  • flash memory can include NOR FLASH, NAND FLASH, 3D NAND FLASH, etc.
  • it can include single-level storage cells (single-level cell, SLC), multi-level storage cells (multi-level cell, MLC), triple-level cell (TLC), quad-level cell (QLC), etc.
  • SLC single-level storage cells
  • MLC multi-level storage cells
  • TLC triple-level cell
  • QLC quad-level cell
  • UFS universal flash storage
  • embedded multimedia memory card embedded multi media Card
  • the random access memory can be directly read and written by the processor 110, and can be used to store executable programs (such as machine instructions) of an operating system or other running programs, and can also be used to store data of users and application programs.
  • the non-volatile memory can also store executable programs and data of users and application programs, etc., and can be loaded into the random access memory in advance for the processor 110 to directly read and write.
  • the external memory interface 120 can be used to connect an external non-volatile memory, so as to expand the storage capacity of the electronic device 100 .
  • the external non-volatile memory communicates with the processor 110 through the external memory interface 120 to implement a data storage function. For example, files such as music and video are stored in an external non-volatile memory.
  • the electronic device 100 can implement audio functions through the audio module 170 , the speaker 170A, the receiver 170B, the microphone 170C, the earphone interface 170D, and the application processor. Such as music playback, recording, etc.
  • the audio module 170 is used to convert digital audio information into analog audio signal output, and is also used to convert analog audio input into digital audio signal.
  • the audio module 170 may also be used to encode and decode audio signals.
  • the audio module 170 may be set in the processor 110 , or some functional modules of the audio module 170 may be set in the processor 110 .
  • Speaker 170A also referred to as a "horn" is used to convert audio electrical signals into sound signals.
  • Electronic device 100 can listen to music through speaker 170A, or listen to hands-free calls.
  • Receiver 170B also called “earpiece” is used to convert audio electrical signals into audio signals.
  • the receiver 170B can be placed close to the human ear to receive the voice.
  • the microphone 170C also called “microphone” or “microphone” is used to convert sound signals into electrical signals. When making a phone call or sending a voice message, the user can put his mouth close to the microphone 170C to make a sound, and input the sound signal to the microphone 170C.
  • the electronic device 100 may be provided with at least one microphone 170C. In some other embodiments, the electronic device 100 may be provided with two microphones 170C, which may also implement a noise reduction function in addition to collecting sound signals. In some other embodiments, the electronic device 100 can also be provided with three, four or more microphones 170C, so as to collect sound signals, reduce noise, identify sound sources, and realize directional recording functions, etc.
  • the earphone interface 170D is used for connecting wired earphones.
  • the earphone interface 170D can be a USB interface 130, or a 3.5mm open mobile terminal platform (OMTP) standard interface, or a cellular telecommunications industry association of the USA (CTIA) standard interface.
  • OMTP open mobile terminal platform
  • CTIA cellular telecommunications industry association of the USA
  • the pressure sensor 180A is used to sense the pressure signal and convert the pressure signal into an electrical signal.
  • pressure sensor 180A may be disposed on display screen 194 .
  • pressure sensors 180A such as resistive pressure sensors, inductive pressure sensors, and capacitive pressure sensors.
  • a capacitive pressure sensor may be comprised of at least two parallel plates with conductive material.
  • the electronic device 100 determines the intensity of pressure according to the change in capacitance.
  • the electronic device 100 detects the intensity of the touch operation according to the pressure sensor 180A.
  • the electronic device 100 may also calculate the touched position according to the detection signal of the pressure sensor 180A.
  • touch operations acting on the same touch position but with different touch operation intensities may correspond to different operation instructions. For example: when a touch operation with a touch operation intensity less than the first pressure threshold acts on the short message application icon, an instruction to view short messages is executed. When a touch operation whose intensity is greater than or equal to the first pressure threshold acts on the icon of the short message application, the instruction of creating a new short message is executed.
  • the gyro sensor 180B can be used to determine the motion posture of the electronic device 100 .
  • the angular velocity of the electronic device 100 around three axes may be determined by the gyro sensor 180B.
  • the gyro sensor 180B can be used for image stabilization. Exemplarily, when the shutter is pressed, the gyro sensor 180B detects the shaking angle of the electronic device 100, calculates the distance that the lens module needs to compensate according to the angle, and allows the lens to counteract the shaking of the electronic device 100 through reverse movement to achieve anti-shake.
  • the gyro sensor 180B can also be used for navigation and somatosensory game scenes.
  • the air pressure sensor 180C is used to measure air pressure.
  • the electronic device 100 calculates the altitude based on the air pressure value measured by the air pressure sensor 180C to assist positioning and navigation.
  • the magnetic sensor 180D includes a Hall sensor.
  • the electronic device 100 may use the magnetic sensor 180D to detect the opening and closing of the flip leather case.
  • the electronic device 100 when the electronic device 100 is a clamshell machine, the electronic device 100 can detect opening and closing of the clamshell according to the magnetic sensor 180D.
  • features such as automatic unlocking of the flip cover are set.
  • the acceleration sensor 180E can detect the acceleration of the electronic device 100 in various directions (generally three axes). When the electronic device 100 is stationary, the magnitude and direction of gravity can be detected. It can also be used to identify the posture of electronic devices, and can be used in applications such as horizontal and vertical screen switching, pedometers, etc.
  • the distance sensor 180F is used to measure the distance.
  • the electronic device 100 may measure the distance by infrared or laser. In some embodiments, when shooting a scene, the electronic device 100 may use the distance sensor 180F for distance measurement to achieve fast focusing.
  • Proximity light sensor 180G may include, for example, light emitting diodes (LEDs) and light detectors, such as photodiodes.
  • the light emitting diodes may be infrared light emitting diodes.
  • the electronic device 100 emits infrared light through the light emitting diode.
  • Electronic device 100 uses photodiodes to detect infrared reflected light from nearby objects. When sufficient reflected light is detected, it may be determined that there is an object near the electronic device 100 . When insufficient reflected light is detected, the electronic device 100 may determine that there is no object near the electronic device 100 .
  • the electronic device 100 can use the proximity light sensor 180G to detect that the user is holding the electronic device 100 close to the ear to make a call, so as to automatically turn off the screen to save power.
  • the proximity light sensor 180G can also be used in leather case mode, automatic unlock and lock screen in pocket mode.
  • the ambient light sensor 180L is used for sensing ambient light brightness.
  • the electronic device 100 can adaptively adjust the brightness of the display screen 194 according to the perceived ambient light brightness.
  • the ambient light sensor 180L can also be used to automatically adjust the white balance when taking pictures.
  • the ambient light sensor 180L can also cooperate with the proximity light sensor 180G to detect whether the electronic device 100 is in the pocket, so as to prevent accidental touch.
  • the fingerprint sensor 180H is used to collect fingerprints.
  • the electronic device 100 can utilize the collected fingerprint characteristics to implement fingerprint unlocking, access to application locks, take pictures with fingerprints, answer incoming calls with fingerprints, and the like.
  • the temperature sensor 180J is used to detect temperature.
  • the electronic device 100 uses the temperature detected by the temperature sensor 180J to implement a temperature treatment strategy. For example, when the temperature reported by the temperature sensor 180J exceeds the threshold, the electronic device 100 may reduce the performance of the processor located near the temperature sensor 180J, so as to reduce power consumption and implement thermal protection.
  • the electronic device 100 when the temperature is lower than another threshold, the electronic device 100 heats the battery 142 to prevent the electronic device 100 from being shut down abnormally due to the low temperature.
  • the electronic device 100 boosts the output voltage of the battery 142 to avoid abnormal shutdown caused by low temperature.
  • the touch sensor 180K is also called “touch device”.
  • the touch sensor 180K can be disposed on the display screen 194, and the touch sensor 180K and the display screen 194 form a touch screen, also called a “touch screen”.
  • the touch sensor 180K is used to detect a touch operation on or near it.
  • the touch sensor can pass the detected touch operation to the application processor to determine the type of touch event.
  • Visual output related to the touch operation can be provided through the display screen 194 .
  • the touch sensor 180K may also be disposed on the surface of the electronic device 100 , which is different from the position of the display screen 194 .
  • the bone conduction sensor 180M can acquire vibration signals. In some embodiments, the bone conduction sensor 180M can acquire the vibration signal of the vibrating bone mass of the human voice. The bone conduction sensor 180M can also contact the human pulse and receive the blood pressure beating signal. In some embodiments, the bone conduction sensor 180M can also be disposed in the earphone, combined into a bone conduction earphone.
  • the audio module 170 can analyze the voice signal based on the vibration signal of the vibrating bone mass of the vocal part acquired by the bone conduction sensor 180M, so as to realize the voice function.
  • the application processor can analyze the heart rate information based on the blood pressure beating signal acquired by the bone conduction sensor 180M, so as to realize the heart rate detection function.
  • the keys 190 include a power key, a volume key and the like.
  • the key 190 may be a mechanical key. It can also be a touch button.
  • the electronic device 100 can receive key input and generate key signal input related to user settings and function control of the electronic device 100 .
  • the motor 191 can generate a vibrating reminder.
  • the motor 191 can be used for incoming call vibration prompts, and can also be used for touch vibration feedback.
  • touch operations applied to different applications may correspond to different vibration feedback effects.
  • the motor 191 may also correspond to different vibration feedback effects for touch operations acting on different areas of the display screen 194 .
  • Different application scenarios for example: time reminder, receiving information, alarm clock, games, etc.
  • the touch vibration feedback effect can also support customization.
  • the indicator 192 can be an indicator light, and can be used to indicate charging status, power change, and can also be used to indicate messages, missed calls, notifications, and the like.
  • the SIM card interface 195 is used for connecting a SIM card.
  • the SIM card can be connected and separated from the electronic device 100 by inserting it into the SIM card interface 195 or pulling it out from the SIM card interface 195 .
  • the electronic device 100 may support 1 or N SIM card interfaces, where N is a positive integer greater than 1.
  • SIM card interface 195 can support Nano SIM card, Micro SIM card, SIM card etc. Multiple cards can be inserted into the same SIM card interface 195 at the same time. The types of the multiple cards may be the same or different.
  • the SIM card interface 195 is also compatible with different types of SIM cards.
  • the SIM card interface 195 is also compatible with external memory cards.
  • the electronic device 100 interacts with the network through the SIM card to implement functions such as calling and data communication.
  • the electronic device 100 adopts an eSIM, that is, an embedded SIM card.
  • the eSIM card can be embedded in the electronic device 100 and cannot be separated from the electronic device 100 .
  • the software system of the electronic device 100 may adopt a layered architecture, an event-driven architecture, a micro-kernel architecture, a micro-service architecture, or a cloud architecture.
  • the software structure of the electronic device 100 is exemplarily described by taking an Android system with a layered architecture as an example.
  • FIG. 11 is an exemplary schematic diagram of the software structure of the electronic device 100 provided by the embodiment of the present application.
  • the layered architecture divides the software into several layers, and each layer has a clear role and division of labor. Layers communicate through software interfaces.
  • the Android system is divided into four layers, which are respectively the application program layer, the application program framework layer, the Android runtime (Android runtime) and the system library, and the kernel layer from top to bottom.
  • the application layer can consist of a series of application packages.
  • the application package may include application programs such as camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, and short message.
  • application programs such as camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, and short message.
  • the data obtained from the respective servers during the running process of the application program may be the synchronization data in the embodiment of the present application.
  • an application program may correspond to one or more copies of source files.
  • the application framework layer provides an application programming interface (application programming interface, API) and a programming framework for applications in the application layer.
  • the application framework layer includes some predefined functions.
  • the application framework layer can include window manager, content provider, view system, phone manager, resource manager, notification manager and so on.
  • a window manager is used to manage window programs.
  • the window manager can get the size of the display screen, determine whether there is a status bar, lock the screen, capture the screen, etc.
  • Content providers are used to store and retrieve data and make it accessible to applications.
  • Said data may include video, images, audio, calls made and received, browsing history and bookmarks, phonebook, etc.
  • the view system includes visual controls, such as controls for displaying text, controls for displaying pictures, and so on.
  • the view system can be used to build applications.
  • a display interface can consist of one or more views.
  • a display interface including a text message notification icon may include a view for displaying text and a view for displaying pictures.
  • the phone manager is used to provide communication functions of the electronic device 100 . For example, the management of call status (including connected, hung up, etc.).
  • the resource manager provides various resources for the application, such as localized strings, icons, pictures, layout files, video files, and so on.
  • the notification manager enables the application to display notification information in the status bar, which can be used to convey notification-type messages, and can automatically disappear after a short stay without user interaction.
  • the notification manager is used to notify the download completion, message reminder, etc.
  • the notification manager can also be a notification that appears on the top status bar of the system in the form of a chart or scroll bar text, such as a notification of an application running in the background, or a notification that appears on the screen in the form of a dialog window.
  • prompting text information in the status bar issuing a prompt sound, vibrating the electronic device, and flashing the indicator light, etc.
  • the Android Runtime includes core library and virtual machine. The Android runtime is responsible for the scheduling and management of the Android system.
  • the core library consists of two parts: one part is the function function that the java language needs to call, and the other part is the core library of Android.
  • the application layer and the application framework layer run in virtual machines.
  • the virtual machine executes the java files of the application program layer and the application program framework layer as binary files.
  • the virtual machine is used to perform functions such as object life cycle management, stack management, thread management, security and exception management, and garbage collection.
  • a system library can include multiple function modules. For example: surface manager (surface manager), media library (Media Libraries), 3D graphics processing library (eg: OpenGL ES), 2D graphics engine (eg: SGL), etc.
  • the surface manager is used to manage the display subsystem and provides the fusion of 2D and 3D layers for multiple applications.
  • the media library supports playback and recording of various commonly used audio and video formats, as well as still image files, etc.
  • the media library can support a variety of audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.
  • the 3D graphics processing library is used to implement 3D graphics drawing, image rendering, compositing, and layer processing, etc.
  • 2D graphics engine is a drawing engine for 2D drawing.
  • System libraries can also include synchronization libraries. Wherein, one or more methods are provided in the synchronization library, so that the electronic device 100 can execute the multi-file synchronization method provided by the embodiment of the present application. More specifically, any application layer application on the electronic device can call the method in the synchronization library, and then synchronize the synchronization data generated by the application.
  • the kernel layer is the layer between hardware and software.
  • the kernel layer includes at least a display driver, a camera driver, an audio driver, and a sensor driver.
  • FIG. 12 is a schematic diagram of another software architecture of the electronic device 100 provided by the embodiment of the present application.
  • the electronic device 100 includes multiple functional modules, such as: a cache management module, a cache scheduling module, and a network detection module.
  • the cache management module can determine synchronization information of copies of multiple source files on the client.
  • the synchronization information may include: the location of dirty pages, the number of dirty pages, whether the file is dirty, the proportion of dirty data to file data, the latest modification time, the latest synchronization time, and the amount of data written.
  • the specific method for the cache management module to determine the synchronization information can refer to the corresponding text description in step S304 in FIG. 3 above, and will not be repeated here.
  • the network detection module can determine the synchronization rate of the communication connection between the client and the server.
  • the specific method for the network detection module to determine the synchronization rate of the communication connection between the client and the server can refer to the text description in step S306 in FIG. 3 above.
  • the cache scheduling module can determine the synchronization priority of the copy of the source file on the client, and the cache scheduling module can also determine the number of files to be synchronized at one time.
  • the cache scheduling module receives the synchronization information determined by the cache management module and the synchronization rate determined by the network detection module.
  • the specific method for the cache scheduling module to determine the synchronization priority of the copy of the source file on the client can refer to the text description in step S306 in FIG. 3 above.
  • the term “when” may be interpreted to mean “if” or “after” or “in response to determining" or “in response to detecting".
  • the phrases “in determining” or “if detected (a stated condition or event)” may be interpreted to mean “if determining" or “in response to determining" or “on detecting (a stated condition or event)” or “in response to detecting (a stated condition or event)”.
  • all or part of them may be implemented by software, hardware, firmware or any combination thereof.
  • software When implemented using software, it may be implemented in whole or in part in the form of a computer program product.
  • the computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on the computer, the processes or functions according to the embodiments of the present application will be generated in whole or in part.
  • the computer can be a general purpose computer, a special purpose computer, a computer network, or other programmable device.
  • the computer instructions may be stored in or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions may be transferred from a website, computer, server, or data center by wire (such as coaxial cable, optical fiber, digital subscriber line) or wireless (such as infrared, wireless, microwave, etc.) to another website site, computer, server or data center.
  • the computer-readable storage medium may be any available medium that can be accessed by a computer, or a data storage device such as a server or a data center integrated with one or more available media.
  • the usable medium may be a magnetic medium (eg, floppy disk, hard disk, magnetic tape), an optical medium (eg, DVD), or a semiconductor medium (eg, a solid-state hard disk), and the like.
  • the processes can be completed by computer programs to instruct related hardware.
  • the programs can be stored in computer-readable storage media.
  • When the programs are executed may include the processes of the foregoing method embodiments.
  • the aforementioned storage medium includes: ROM or random access memory RAM, magnetic disk or optical disk, and other various media that can store program codes.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Hardware Design (AREA)
  • Databases & Information Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Software Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

本申请提供多文件同步方法及电子设备。该方法包括:客户端在同步本地的多个源文件的副本的同步数据时,首先确定该多个源文件副本的老化程度和同步数据的数据量,并基于老化程度和同步数据的数据量确定多个源文件的副本的同步优先级,进而客户端依据多个源文件副本的同步优先级进行同步。本申请提供的多文件同步方法,通过综合考虑客户端源文件副本的老化程度和同步数据量,即避免了客户端总是优先同步同步数据小的源文件副本而在后同步很久没有被同步的同步数据大的源文件副本,并且降低了平均同步时长。

Description

多文件同步方法及电子设备
本申请要求于2021年07月22日提交中国专利局、申请号为202110832126.5、申请名称为“多文件同步方法及电子设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及电子技术领域,尤其涉及多文件同步方法及电子设备。
背景技术
随着通信技术的发展以及智能设备的普及,万物互联的人工智能物联网(artificial intelligence&internet of things,AIoT)时代正在到来。受益于操作系统的分布式互联能力的提高,智能穿戴设备、智能家居设备、移动终端等设备可以通过网络进行数据交互,并且基于该数据交互去协作实现特定的功能。
当服务端将一个或多个文件共享到客户端时,客户端会将该一个或多个共享文件存储到本地缓存中。当用户修改客户端上的共享文件时,客户端需要将修改后的共享文件同步至服务端上。例如,用户将手机上的文档文件共享到电脑上进行修改,此时电脑需要不断的向手机同步经过用户修改的文档文件。
为了实现共享文件在客户端与服务端之间的同步,客户端可以在用户每次修改共享文件后马上进行同步;或者,客户端可以在本地积累一定量的同步数据后,然后进行同步。
但是,当客户端与服务端之间存在多个共享文件需要同步时,彼此独立的各个共享文件的同步过程会互相干扰,增加同步时间,降低了用户的体验。
发明内容
本申请实施例提供了一种多文件同步方法及电子设备。本申请提供的多文件同步方法,基于文件的老化程度和同步数据的数据量确定文件的同步优先级,进而基于同步优先级确定文件的同步先后顺序。客户端在实施该方法同步多个文件时,既能保证客户端不会优先同步老化程度较小的文件,并且可以降低多个文件的平均同步时长。
第一方面,本申请提供一种多文件同步方法,该方法包括:
客户端从服务端获取多个文件副本;客户端确定该多个文件副本的同步信息,该同步信息包括同步数据的数据量和老化程度,该老化程度对应于文件副本的未被同步时长;该客户端基于该多个文件副本的同步信息以及第一预设条件确定该多个文件副本的同步优先级;该第一预设条件包括:在该文件副本的老化程度位于第一范围的情况下,该文件副本的同步优先级与该文件副本的老化程度有关;在该文件副本的老化程度位于第二范围的情况下,该文件副本的同步优先级与该文件副本的同步数据的数据量有关。
在上述实施例中,客户端可以根据文件的老化程度和同步数据的数据量确定文件副本的同步优先级。首先,若只依据文件副本的同步数据的数据量确定文件副本的同步优先级,则客户端在后同步的文件被修改后,该文件的同步数据的数据量增加,反而会导致更不优先被同步;其次,若只依据文件副本的老化程度进行同步,则客户端平均同步时长较长。而,客户端实施本申请提供的多文件同步方法,既能保证客户端上不会有文件副本优先级一直较高而一直不被同步,并且能够减少多个文件副本的平均同步时长。
结合第一方面的一些实施例,在一些实施例中,该客户端确定第一同步速率;该客户端基于该第一同步速率和该多个文件副本的优先级确定待同步文件集合;该客户端同步待同步文件集合中的文件副本。
在上述实施例中,客户端在确定多个文件副本的同步优先级后,可以预测同步速率,进而确定待同步文件集合,避免客户端将所有的待同步文件积压在客户端上的协议栈或协议栈的缓存中,减少协议栈的负载。
结合第一方面的一些实施例,在一些实施例中,该客户端确定历史同步速率,该历史同步速率与历史同步的同步数据的数据量和历史同步的同步时长有关;该客户端基于该历史同步速率确定该第一同步速率。
在上述实施例中,由于不同服务端的接收数据的能力,以及客户端与服务端之间建立的通信连接的类型不一样,客户端可以基于历史同步速率预测第一同步速率。
结合第一方面的一些实施例,在一些实施例中,该客户端基于该第一同步速率和预期同步时长确定同步数据的数据量;该客户端基于该同步数据的数据量和该多个文件副本的同步优先级确定该待同步文件集合。
在上述实施例中,该客户端可以基于第一同步速率,确定本次同步的发送的数据量,进而基于多个文件副本的同步优先级确定待同步文件的集合。
结合第一方面的一些实施例,在一些实施例中,该同步数据包括脏数据或写操作。
结合第一方面的一些实施例,在一些实施例中,该客户端基于页的脏比特dirty bit确定多个文件副本的同步信息;或者,该客户端基于写操作确定多个文件副本的同步信息。
在上述实施例中,客户端基于脏比特确定多个文件副本的同步信息需要遍历缓存;若客户端基于写操作确定多个文件副本的同步信息,则可以不遍历缓存,降低计算量。
结合第一方面的一些实施例,在一些实施例中,该同步信息还包括:脏页的位置、脏页的数量、同步数据占文件的比例、最近修改时刻、最近同步时刻中的至少一种。
在上述实施例中,客户端最少要根据老化程度、同步数据量确定文件副本的同步优先级,还可以根据同步信息中的其他参数确定文件副本的同步优先级。
结合第一方面的一些实施例,在一些实施例中,该第一范围的下限大于等于该第一范围的上限;位于第一范围的文件副本的同步优先级小于该位于第二范围的文件副本的同步优先级;同步优先级小的文件副本会被优先同步。
在上述实施例中,第一范围的下限大于等于第二范围的上限时,相比于位于第二范围的文件副本,位于第一范围的文件副本的老化程度较高,故配置较小的同步优先级,使得很久没有被同步的文件副本可以优先被同步。
结合第一方面的一些实施例,在一些实施例中,该第一范围的上限小于该第一范围的下限;位于第一范围的文件副本的同步优先级大于该位于第二范围的文件副本的同步优先级;同步优先级小的文件副本会被优先同步。
在上述实施例中,第一范围的上限小于等于第二范围的下限时,相比于位于第二范围的文件副本,位于第一范围的文件副本的老化程度较低,故配置较大的同步优先级,使得很久没有被同步的文件副本可以优先被同步。
结合第一方面的一些实施例,在一些实施例中,该多个文件副本包括第一文件副本、第二文件副本;该第一文件副本的老化程度位于该第一范围,该第一文件副本的老化程度位于该第一范围;在该第一文件副本的老化程度小于该第二文件副本的老化程度情况下,该第一文件副本的同步优先级大于该第二文件副本的同步优先级;在该第一文件副本的老化程度大 于该第二文件副本的老化程度情况下,该第一文件副本的优先级小于该第二文件副本的同步优先级;同步优先级小的文件副本会被优先同步。
在上述实施例中,当第一文件副本、第二文件副本的老化程度位于该第一范围时,可以进一步根据老化程度的大小,确定该第一文件副本、第二文件副本之间的同步顺序。
结合第一方面的一些实施例,在一些实施例中,在该第一文件副本的老化程度等于该第二文件副本的老化程度情况下,并且在该第一文件副本的同步数据的数据量小于该第二文件副本的同步数据的数据量情况下,该第一文件副本的同步优先级小于该第二文件副本的同步优先级;在该第一文件副本的老化程度等于该第二文件副本的老化程度情况下,并且在该第一文件副本的同步数据的数据量大于该第二文件副本的同步数据的数据量情况下,该第一文件副本的同步优先级大于该第二文件副本的同步优先级。
在上述实施例中,当第一文件副本、第二文件副本的老化程度位于该第一范围时,且第一文件副本、第二文件副本的老化程度一致时,客户端基于同步数据的数据量确定第一文件副本和第二文件副本之间的同步顺序,进而降低多个文件副本的平均同步时长。
结合第一方面的一些实施例,在一些实施例中,在该第一文件副本的老化程度等于该第二文件副本的老化程度情况下,该第一文件副本的同步优先级等于该第二文件副本的同步优先级。
结合第一方面的一些实施例,在一些实施例中,该多个文件副本包括第三文件副本、第四文件副本;该第三文件副本的老化程度位于该第二范围,该第四文件副本的老化程度位于该第二范围;在该第三文件副本的同步数据的数据量小于该第四文件副本的同步数据的数据量情况下,该第三文件副本的同步优先级小于该第四文件副本的同步优先级;在该第三文件副本的同步数据的数据量大于该第四文件副本的同步数据的数据量情况下,该第三文件副本的同步优先级大于该第四文件副本的同步优先级;同步优先级小的文件副本会被优先同步。
在上述实施例中,当第三文件副本、第四文件副本的老化程度位于第二范围时,客户端可以优先同步同步数据量小的文件,进而降低平均同步时长。
第二方面,本申请实施例提供了一种电子设备,该电子设备包括:一个或多个处理器和存储器;该存储器与该一个或多个处理器耦合,该存储器用于存储计算机程序代码,该计算机程序代码包括计算机指令,该一个或多个处理器调用该计算机指令以使得该电子设备执行如第一方面以及第一方面中任一可能的实现方式描述的方法。
第三方面,本申请实施例提供了一种芯片系统,该芯片系统应用于电子设备,该芯片系统包括一个或多个处理器,该处理器用于调用计算机指令以使得该电子设备执行如第一方面以及第一方面中任一可能的实现方式描述的方法。
第四方面,本申请实施例提供一种包含指令的计算机程序产品,当上述计算机程序产品在电子设备上运行时,使得该电子设备执行如第一方面以及第一方面中任一可能的实现方式描述的方法。
第五方面,本申请实施例提供一种计算机可读存储介质,包括指令,当上述指令在电子设备上运行时,得该电子设备执行如第一方面以及第一方面中任一可能的实现方式描述的方法。
可以理解地,上述第二方面提供的电子设备、第三方面提供的芯片系统、第四方面提供的计算机程序产品以及第五方面提供的计算机存储介质均用于执行本申请实施例所提供的方法。因此,其所能达到的有益效果可参考对应方法中的有益效果,此处不再赘述。
附图说明
图1A为本申请涉及的网络文件系统的一个示例示意图;
图1B为本申请涉及的回写机制的一个示例性示意图;
图1C为本申请涉及的回写机制中的依赖图的一个示例性示意图;
图1D为本申请涉及的回写机制中的事务的一个示例性示意图;
图1E为本申请涉及的回写机制中的写屏障的一个示例性示意图;
图1F为本申请涉及的回写机制中的维持(persist)的一个示例性示意图;
图2A与图2B为本申请涉及的文件写回同步方法的一个示例性示意图;
图2C与图2D为本申请涉及的实施文件写回同步方法场景的一个示例性示意图;
图3为本申请实施例提供的多文件同步方法的一个示例性示意图;
图4A、图4B为本申请实施例提供的客户端与服务端通信连接的一个示例性示意图;
图5为本申请实施例提供的确定同步信息方法的一个示例性示意图;
图6为本申请实施例提供的确定同步的文件数量的方法的一个示例性示意图;
图7为本申请实施例提供的确定一次同步的文件或文件的脏数据的方法的一个示例性示意图;
图8为本申请实施例提供的超时机制的一个示例性示意图;
图9A、图9B为本申请实施例提供的多文件同步场景的一个示例性示意图;
图10为本申请实施例提供的电子设备100的硬件结构的一个示例性示意图;
图11为本申请实施例提供的电子设备100的软件结构的一个示例性示意图;
图12为本申请实施例提供的电子设备100的另一个软件架构示意图。
具体实施方式
本申请以下实施例中所使用的术语只是为了描述特定实施例的目的,而并非旨在作为对本申请的限制。如在本申请的说明书和所附权利要求书中所使用的那样,单数表达形式“一个”、“一种”、“该”、“上述”、“该”和“这一”旨在也包括复数表达形式,除非其上下文中明确地有相反指示。还应当理解,本申请中使用的术语“和/或”是指并包含一个或多个所列出项目的任何或所有可能组合。
以下,术语“第一”、“第二”仅用于描述目的,而不能理解为暗示或暗示相对重要性或者隐含指明所指示的技术特征的数量。由此,限定有“第一”、“第二”的特征可以明示或者隐含地包括一个或者更多个该特征,在本申请实施例的描述中,除非另有说明,“多个”的含义是两个或两个以上。
网络文件系统(networkfilesystem,NFS)支持客户端以类似访问本地文件的方式通过网络访问服务端上的源文件。为了保证客户端源文件的副本与服务端源文件的数据一致性,需要客户端与服务端进行同步。其中,数据一致性是指客户端上缓存的源文件的副本与服务端上的源文件数据相同。其中,同步是客户端发起的,用于实现数据一致性的行为。
客户端执行同步行为的客体可以是脏数据,或者可以是客户端修改缓存中的源文件的副 本的写的I/O操作(简称写操作)。为了方便阐述,称同步行为的客体为同步数据,同步数据可以是脏数据也可是写操作。
其中,脏数据为客户端上被修改但还未被同步到服务端的数据,即脏数据为客户端上源文件的副本与服务端上源文件不一致的数据。
其中,客户端同步脏数据可以实现最终状态的数据一致性;客户端同步写操作可以实现中间状态、最终状态的数据一致性。
其中,最终状态是指同步完成后数据的状态;中间状态是指最终状态之前源文件和源文件的副本的数据变化过程的状态。
首先,下面以同步数据为写操作为例,示例性的介绍单文件的同步方法。
图1A为本申请涉及的网络文件系统的一个示例示意图。
如图1A所示,客户端与服务端建立通信连接后,服务端可以将源文件映射到客户端本地中,客户端可以通过系统调用(systemcall)操作虚拟文件系统,进而操作该源文件。
其中,客户端修改服务端上的源文件时,修改操作会被远程过程调用(Remoteprocedurecall,RPC)传递到服务端,由服务端基于该修改操作完成对源文件的修改,进而实现客户端与服务端的同步。
很显然的,若客户端与服务端之间的通信连接的传输速率波动较大,或者传输速率较低,则在服务段基于该修改操作完成对源文件的修改前,源文件处于可读状态,不可以被客户端修改,用户体验较差。
为了减少客户端与服务端的通信连接的传输速率波动导致的客户端与服务端之间的较大的延迟,提升用户的体验,服务端可以将共享文件的部分或全部的数据发送到客户端,客户端会将该共享文件的部分或全部的数据存储在缓存中。
图1B为本申请涉及的回写机制的一个示例性示意图。
与图1A不同的是,客户端可以将服务端的源文件的部分或全部数据保存在本地的缓存中,并利用队列或者其他的数据结构组织所有和源文件副本相关的数据页,进而不需要通过RPC进行网络访问,降低了客户端修改源文件副本的开销和延迟。
如图1B所示,客户端修改源文件的副本时,触发回写机制,将一个或若干个修改操作可以分为一个或若干个写操作,并将该一个或若干个写操作发送到服务端。服务端在收到该一个或若干个写操作后,可以暂时不处理该一个或若干个写操作,并向客户端发送响应以告知客户端:服务端已经收到了该一个或若干个写操作。
其中,该一个或若干个写操作可以使得客户端上缓存的源文件的副本与服务端上的源文件的数据保持一致性,进而实现同步。即,单文件的一次同步包括该一个或若干个写操作。
客户端接收到该响应后,可以继续修改源文件的副本。在后续的某个时刻,客户端可以向服务端发送请求,服务端收到该请求后,可以基于之前收到的一个或若干个写操作完成本地源文件的修改。此时,客户端与服务端的一次同步完成。
可以理解的是,由于不需要等待服务端基于写操作更新服务端本地的源文件,实现了非阻塞式的同步,在同步过程中允许客户端修改源文件的副本,进而有助于提升用户体验。
值得说明的是,回写机制中同步的数据可以不是写操作,而是源文件的副本的脏数据。
为了进一步提升回写机制的中间状态的数据一致性,保证写回的数据与写入时的数据保持一致,可以建立依赖图以保证中间状态的数据一致性。
图1C为本申请涉及的回写机制中的依赖图的一个示例性示意图。
如图1C所示,依赖图中每一个节点对应一个写操作,以及该写操作涉及到的数据,箭头的顺序表示代表不同写操作之间的先后依赖关系,即箭头指向数据的同步之前必须要保证指向该数据的数据同步完成。
例如,如图1C所示,若是将5号节点对应的数据进行同步,则在同步前需要保证5号节点依赖的数据均完成同步。即,需要1号节点、2号节点、3号节点、4号节点对应的数据均完成同步。
例如,客户端上存在两个变量:x和y,其中,当用户修改x时,y会自动的变化;当用户修改y时,x不会自动的变化。例如,修改x时,y的值的变化为y=x+5。
其中,x的值为5号节点对应的数据,y的值可以是4号节点对应的数据。用户在客户端上顺序修改的内容包括:首先修改y的值为2,其次修改x的值为1。修改后,客户端上的x的值为1,y的值为6。
则,若是客户端先同步x的修改操作,后同步y的修改操作。则服务端上的数据包括:x的值为1,y的值为1,与客户端上的数据不具有一致性。若是,根据依赖图,先同步y的修改操作,后同步x的修改操作,则服务端上的数据与客户端上的数据具有一致性。
进一步的,可以将一组具有依赖关系的写操作作为一个不可分的事务(transaction)去进行同步。其中,事务为不可分的同步的最小单位。其中,事务的同步可以通过commit完成,并存储在内存中的日志(journal)中。
图1D为本申请涉及的回写机制中的事务的一个示例性示意图。
如图1D所示,2号节点依赖于1号节点,并且没有任何节点依赖于2号节点时,可以将1号节点对应的数据以及2号节点对应的数据的写操作当作一个不可分的事务去进行同步。
图1E为本申请涉及的回写机制中的写屏障的一个示例性示意图。
为了保证客户端上共享文件副本的数据与服务端上共享文件的数据的一致性,客户端的写入请求需要在缓存的flush指令前完成,其中相邻两个flush指令的时间间隔可以称为epoch。其中,每一个flush指令可以称为一个写屏障(writebarrier)。
如图1E所示,在一个epoc内的写操作的顺序可以变化;在不同epoc内的写操作是相对有序的。例如,写操作1和写操作2的顺序可以变化,但是写操作1必须要在写操作3前。
为了应对内存掉电等特殊情况,客户端还可以将缓存中的源文件的副本、源文件的副本在缓存中的位置以及源文件在服务端中的位置存储在ROM/flashmemory等非易失性存储介质中。
图1F为本申请涉及的回写机制中的维持(persist)的一个示例性示意图。
如图1F所示,客户端可以将每次对缓存中的源文件的副本修改时,客户端可以将修改操作的副本保存在非易失性存储介质中。例如,客户端的源文件的副本包括数据A,其中数据A的值被客户端修改后还未被同步。在客户端修改数据A的值之后,客户端可以将修改数据A的写操作、数据A在客户端缓存中的位置以及数据A在服务端中的位置保存在非易失性存储介质中。当缓存掉电导致数据丢失,客户端可以再次从服务端获取源文件的副本,并从非易失性存储介质恢复客户端的修改操作,进而恢复客户端上掉电前的源文件的副本的状态。
图1A至图1F对应的文字描述主要介绍同步单个文件时的回写机制的内容,下面介绍本申请涉及的一种文件同步方法,以及该方法在同步多个文件时面临的问题。
下面结合图2A、图2B所示的内容示例性的介绍本申请涉及的一种文件同步方法。
图2A与图2B为本申请涉及的文件写回同步方法的一个示例性示意图。
如图2A所示,服务端可以通过网络向客户端共享多个源文件,包括文件1和文件2。客户端在收到服务端发送的源文件的副本后,可以将源文件的副本的部分或全部数据存储在客户端本地缓存中。
受限于客户端上本地缓存的大小,当用户浏览、修改文件1时,需要将缓存中的数据换出并将换出的脏数据与服务端进行同步。
如图2B所示,若用户在电子设备上浏览、修改文件1时,产生了的文件1的脏数据。电子设备会将该在脏数据存储在电子设备的缓存中,若缓存已满,需要淘汰一部分脏数据。
例如,被淘汰的脏数据为文件2的脏数据,则可以将文件2的其他的部分或全部的脏数据一并进行同步,并在同步成功后删除已经同步成功的脏数据。
若在同步文件2的脏数据时,客户端与服务端之间的通信连接的数据传输速率较低,或者,文件2的旧的脏数据的数据量较大,则会导致网络拥塞,降低后续其他文件的同步时间,进而影响后续其他文件的同步。
又例如,被淘汰的脏数据为文件1的脏数据,则可以将文件1的其他的旧的脏数据一并进行同步。类似的,若在同步文件1的脏数据时,客户端与服务端之间的网络传输速率较低,或者,文件1的脏数据的数据量较大,则会导致网络拥塞,降低后续其他文件的同步时间,进而影响后续其他文件的同步。
图2C与图2D为本申请涉及的实施文件写回同步方法场景的一个示例性示意图。
由于客户端与服务端之间通信连接的数据传输速率是时变的,故客户端在不同时刻进行相同数据量的脏数据同步也会导致不同的同步时长。
如图2C所示,当客户端在同步时刻1时开始同步,在同步时刻2完成该次同步,花费的时长为同步时长1;当客户端在同步时刻3时开始同步,在同步时刻4完成该次同步,花费的时长为同步时长2。
由于客户端与服务端之间的通信连接的数据传输速率在同步时刻1至同步时刻2之间较高,而在同步时刻3至同步时刻4之间较低,故同步时长1小于同步时长2。
进一步的,在大多数情况下,客户端往往需要向服务端同步多个文件。在该情况下,本申请涉及的文件写回同步方法可以优先同步被客户端换出缓存的文件,或者随机选择文件或文件的脏数据进行优先同步。而当换出缓存的文件体积或脏数据的数据量较大时,该文件的缓存时间较长,增加后续其他文件的同步时长。
如图2D所示,客户端在第0秒开始向服务端依次同步文件1、文件2、文件3。其中,文件1的脏数据的数据量为1020kb、文件2的脏数据的数据量为500kb、文件3的脏数据的数据量为460kb,且客户端与服务端之间的网络传输速率为200kb/s。
首先,在第5.1s时,客户端将文件1的脏数据全部发送出去,完成文件1的同步。
其次,对于文件2来说,当文件2在第5.1s前需要被同步,需要等待文件1同步后才能开始数据传输。例如,在第0s时,客户端开始同步文件1,但是在第5.1s时,才会开始传输文件2的脏数据,在第7.6s时,客户端将文件2的脏数据全部发送出去,完成文件2的同步。
再次,对于文件3来说,当文件需要在第7.6s前需要被同步,需要等待文件1和文件2同步后才能开始数据传输。例如,在第0s时,客户端开始同步文件3,但是在第7.6s时,才会开始传输文件3的脏数据,在第9.9s时,客户端将文件3的脏数据全部发送出去,完成文件2的同步。
可以理解的是,本申请涉及的文件写回同步方法中被同步的文件具有随机性,导致了在后同步文件的同步时长较长。进一步的,若是在网络传输速率较低时,同步数据的数据量较 大的文件,则会极大程度的增加后续其他文件的同步时长。
为了降低多文件同步的平均同步时间,本申请实施例提供了一种多文件同步方法。本申请实施例提供的多文件同步方法包括:首先,客户端会基于历史同步速率,预测当前时刻的同步速率;其次,客户端会基于预测的同步速率、源文件的副本的同步信息确定每个同步文件的优先级;最后基于同步文件的优先级确定待同步文件集合,并进行同步。
为了方便描述,文件指代客户端上源文件的副本。
下面示例性的介绍,本申请实施例提供的多文件同步方法。
图3为本申请实施例提供的多文件同步方法的一个示例性示意图。
如图3所示,本申请实施例提供的多文件同步方法包括:
S301:服务端与客户端建立通信连接。
具体的,客户端与服务端建立通信连接。
服务端为向客户端提供共享文件的电子设备,客户端为接收服务端共享文件的电子设备。
其中,客户端/服务端可以是终端设备,如手机、平板电脑、虚拟现实终端设备、增强现实终端设备、工业控制中的无线终端、无人驾驶中的无线终端、远程医疗中的无线终端、智能电网中的无线终端、运输安全中的无线终端、智慧城市中的无线终端、智慧家庭中的无线终端、可穿戴设备、车载设备等。
其中,服务端可以是为客户端服务的,服务端可以向客户端提供源文件以及保存客户端数据等,并且服务端也可以称为服务器。
值得说明的是,客户端可以是发起通信连接的端点,也可以是接收通信连接的端点。
其中,客户端与服务端建立的通信连接的类型取决于客户端和服务端上协议栈的能力。当客户端和服务端上的协议栈均支持多路径传输协议如MPTCP协议、多路径快速UDP网络连接协议(multipath quick udp internet connection,MPQUIC)等时,客户端与服务端之间可以存在多条用于传输数据的路径(path)。
下面结合图4A、图4B所示的内容为例,示例性的介绍客户端与服务端之间的通信连接。
图4A、图4B为本申请实施例提供的客户端与服务端通信连接的一个示例性示意图。
如图4A所示,客户端可以为移动终端,例如手机。手机同时通过基站以及路由器与服务端进行通信。示例性的,基站向手机分配的IP地址为IP1,路由器向手机分配的IP地址为IP2,手机上源端口为80。服务端的IP地址为IP3,服务端上目标端口为1314。在该情况下,手机可以通过第一物理路径:(IP1、80、IP3、1314)以及第二物理路径:(IP2、80、IP3、1314)与服务端进行通信。
其中,在近场场景中客户端还可以通过近距离通信服务与服务端建立通信连接。其中,近距离通信服务可以包括:蓝牙、苹果无线直连连接(Apple Wireless Direct Link,AWDL)、HiLink、ZigBee等。
如图4B所示,客户端可以为PC,服务端可以为手机。手机分别通过蓝牙、路由器与PC建立连接。
可以理解的是,根据客户端上协议栈和服务端上协议栈的能力,客户端与服务端可以多种不同的方式建立通信连接。
S302:服务端向客户端共享源文件。
具体的,在客户端和服务端建立通信连接后,服务端向客户端发送源文件的副本,以共 享该源文件。
其中,服务端向客户端共享源文件可以是响应于客户端的请求,或者服务端向客户端共享源文件可以是建立通信链接后自动的共享。
S303:客户端将获取的源文件的副本存储在缓存中。
具体的,客户端在收到服务端的源文件的副本后,可以将源文件的副本的全部数据存储在缓存中,如RAM的页高速缓存中(pagebuffer)中,或者其他随机存取存储介质、非易失性存储介质中。或者,客户端在收到服务端的源文件的副本后,可以将源文件的副本的部分数据存储在缓存中,剩余的部分可以存储在客户端上的非易失性存储介质中,如ROM/flashmemory中。
其中,若是将源文件的副本的部分数据存储在缓存中,该源文件的副本的部分数据可以是会被客户端经常修改的源文件的副本的数据。
S304:客户端修改源文件的副本时,确定同步信息。
具体的,客户端修改源文件时,可以确定/更新该源文件的副本的同步信息。其中,同步信息包括:脏页所在的位置、脏页数、文件是否为脏、脏数据占文件数据的比例、最近修改时刻、最近同步时刻、写操作的数据量等。
客户端可以基于写操作确定被修改的文件,以及被修改的数据。或者,客户端可以根据页的dirtybit标识确定该页是否是脏页(dirtypage),脏页为脏数据。
其中,写操作可以包括:被写入的文件、该被写入的文件需要被修改的页以及需要修改的数据。例如,写操作的格式可以为write(file,buf,&pos)。其中,写操作的输入参数可以包括文件file,修改的数据buf和修改的数据的位置&pos。其中数据的位置&pos可以确定被修改的页。
下面结合图5、表1所示的内容,示例性的介绍确定同步信息的方法。
图5为本申请实施例提供的确定同步信息方法的一个示例性示意图。
如图5所示,客户端对缓存中的源文件的副本进行写操作时,可以通过写操作确定被修改的文件,以及被修改的数据位于文件的页的位置。
表1为本申请实施例提供的文件脏数据统计的一个示例性示意表。
表1
Figure PCTCN2022106900-appb-000001
客户端的缓存中的源文件的副本包括:文件1、文件2和文件3。其中,文件1包括2个脏页、脏数据量为8KB,脏数据比例为28.57%、最近修改时刻为T1、最近同步时刻为T2;文件2包括4个脏页、脏数据量16KB、脏数据比例50%、最近修改时刻为T3、最近同步时刻为T4;文件3包括1个脏页,脏数据量4KB、脏数据比例20%、最近修改时刻为T5、最近同步时刻为T6。
或者,客户端也可以遍历缓存中的页的dirtybit标识确定每个文件的脏页。
可以理解的是,在修改源文件的副本时,客户端可以基于修改操作去确定源文件的副本 的同步信息。
S305:客户端基于同步信息确定多个文件的同步优先级。
具体的,客户端可以有多种方法基于同步信息确定多个文件的同步优先级。其中,客户端可以出于不同的准则选取不同的方法确定文件的同步优先级。
可选的,客户端可以基于同步数据的数据量占源文件的副本的比例、文件的被修改频率、最近同步时刻等参数,在确定文件的同步优先级前,将客户端上需要同步的文件进行分组。其中,可以根据用户的选择或者客户端预置的规则,确定组之间的同步顺序,组内的文件同步顺序由组内的文件同步优先级决定。
例如,按照最近修改时刻进行分组。10s内被修改过的文件分为第一组、10s-20s内被修改过的文件分为第二组、20s-30内被修改过的文件分为第三组等。在每一组内的文件的同步优先级可以按照下文的方式确定组内的文件同步优先级。又例如,按照修改频次进行分组,10s内修改过0-5次的文件分为第一组,10s内修改过6-10次的文件分为第二组、10s内修改过11-15次的文件分为第三组等。又例如,可以基于多个参数确定文件的分组。
下面具体的介绍确定文件同步优先级的方法:
其一,客户端可以根据老化程度确定多个文件的同步优先级。
客户端可以确定缓存中源文件的副本的老化程度,其中,老化程度可以与该文件的最近同步时刻有关。
例如,Age degree=(T now-T rec)k1,Age degree为源文件的副本的老化程度,T now为现在的时刻,T rec为源文件的副本的最近同步时刻,k1为老化系数1,(T now-T rec)为该源文件副本的未被同步时长。其中不同文件的老化系数可以不一样。例如,对于用户修改频次高的文件、多用户使用的文件的老化系数可以较高。
又例如,
Figure PCTCN2022106900-appb-000002
其中,T 1为预设的老化时间阈值1。
又例如,
Figure PCTCN2022106900-appb-000003
其中,T 2为预设的老化时间阈值1。
其中,k2为老化系数2。
客户端确定缓存中源文件的副本的老化程度后,可以确定该文件的同步优先级。
例如,文件的同步优先级等于负的老化程度。其中,文件同步优先级值越小,越优先被同步。
其中,当多个文件的老化程度一致时,或多个文件的同步优先级相同时,客户端可以基于同步数据的数据量确定者多个文件内的同步顺序。例如,多个文件的同步数据的数据量小的文件会被优先同步。
可以理解的是,优先同步老化程度大的文件,可以避免客户端总是同步新产生同步数据的文件而一直忽略同步之前时刻被修改的文件,进而使得客户端上的最大老化程度的文件的老化程度较低,进而有助于保持客户端与服务端的数据差距始终维持在一个较小的范围内。
其二,客户端可以根据同步数据的数据量或同步数据的数据量占源文件的副本的比例确定多个文件的同步优先级。
如图5以及表1所示,客户端可以确定源文件的副本的同步数据的数据量,进而确定多个文件的同步优先级。
例如,文件同步优先级等于负的文件的同步数据的数据量,或者文件同步优先级=负的文件同步数据的数据量占源文件的副本的比例。具体的,例如,当同步数据为脏数据时,文件的同步优先级等于源文件的副本的负的脏数据量或负的脏数据比例*100。当同步数据为写操作时,文件的同步优先级等于源文件的副本的负的写操作的数据量或同步数据的数据量占源文件的副本的比例*100。
可以理解的是,当客户端根据同步数据的数据量或同步数据的数据量占源文件的副本的比例确定多个文件的同步优先级时,会优先同步同步数据的数据量大的文件或者会优先同步数据的数据量占源文件的副本的比例较大的文件。
可以理解的是,考虑到同步数据的数据量较大的文件更可能是用户经常修改的文件,故客户端可以优先同步同步数据的数据量大的文件,进而提升用户的体验。
值得说明的是,当同步数据时脏数据时,使用同步数据的数据量而非文件的修改频次确定同步文件的优先级,更具有稳健性。例如,用户修改文件1的变量Z为1、3、5、1,在该情况下,文件1的同步数据的数据量为0,不需要对文件1进行同步,或者是不需要优先同步文件1。但是根据文件的修改频次确定同步文件的优先级,则会优先对文件1进行同步。
其三,客户端可以根据同步数据的数据量和老化程度确定多个文件的同步优先级。
例如,
Figure PCTCN2022106900-appb-000004
其中,T 2为预设的老化时间阈值2。
或者,
Figure PCTCN2022106900-appb-000005
其中,同步系数可以与同步数据的数据量的类别有关,即同步数据为脏数据时的同步系数与同步数据为写操作时的同步系数不同。例如,文件1副本的同步数据为脏数据时,文件1副本同步系数为1;文件2副本的同步数据为写操作时,同步系数为0.9。或者,文件2副本的同步数据为写操作时,同步系数为1.1。
其中,当多个文件的同步数据的数据量*同步系数的值一样时,或多个文件的同步优先级相同时,客户端可以基于老化程度确定者多个文件内的同步顺序。
又例如,
Figure PCTCN2022106900-appb-000006
或者,
Figure PCTCN2022106900-appb-000007
其中,T 3为预设的老化时间阈值3。
又例如,
Figure PCTCN2022106900-appb-000008
又例如,
Figure PCTCN2022106900-appb-000009
其中,T 4为预设的老化时间阈值4。
可以理解的是,客户端还可以通过多种方式确定文件的同步优先级,在此不做限定。
值得说明的是,本申请实施例提供的文件的同步优先级,在多数情况下,会使得同步数据小的优先级较高,进而优先同步。具体的,当文件的老化程度大于阈值时,优先与老化程度低于阈值的文件同步,进而避免了客户端总是优先同步新产生的同步数据导致而延后同步老化程度较高的文件导致的客户端与数据段不一致的情况,提升了用户体验。
值得说明的是,在本申请实施例中,确定文件的同步优先级的方法与客户端同步文件的方式有关。例如,当客户端同步脏数据时,则在大部分情况下,文件的脏数据量越小,优先级越高。又例如,当客户端同步写操作时,则在大部分情况下,文件的写操作量越小,优先级越高。
或者,客户端可以根据同步数据的数据量和/或老化程度确定多个文件的同步优先级。
例如,
Figure PCTCN2022106900-appb-000010
其中,T 5为预设的老化时间阈值5。
又例如,
Figure PCTCN2022106900-appb-000011
其中,T 6为预设的老化时间阈值6,其中F(同步数据的数据量,Age degree)为预置的函数,输出为文件的同步优先级。
Figure PCTCN2022106900-appb-000012
其中,T 7为预设的老化时间阈值7、T 8为预设的老化时间阈值8。
值得说明的是,每次同步源文件的副本后,客户端需要更新文件的同步信息。
S306:客户端基于文件的同步优先级以及同步速率确定待同步文件集合。
具体的,在同步前,客户端基于过去一个或多个时间切片内同步速率,预测当前时刻同步速率。客户端可以基于同步速率,确定一次同步的同步数据的数据量,进而基于同步数据的数据量以及文件的同步优先级确定待同步文件集合。
其中,同步速率可以是客户端与服务端之间的同步数据的传输速率,或者可以是客户端发送同步数据的速率,或者可以是服务端接收同步数据的速率。
可选的,在本申请一些实施例中,可以基于同步速率对客户端与服务端之间的通信连接 进行分级,进而根据通信连接的级别确定同步的同步数据的数据量。
表2为本申请实施例提供的通信连接分级的一个示例性示意表。
表2
通信连接的等级 同步速率 同步数据的数据量
等级1/优 大于500KB/S 同步速率*期望的同步时长
等级2/优 400-500KB/S 同步速率*期望的同步时长
等级3/良 350-400KB/S 同步速率*期望的同步时长
等级4/良 300-350KB/S 同步速率*期望的同步时长
等级5/中 150-300KB/S 同步速率*期望的同步时长
等级6/差 75-150KB/S 同步速率*期望的同步时长
等级7/差 0-75KB/S 同步速率*期望的同步时长
如表2所示,客户端可以基于同步速率确定通信连接的等级,并且确定一次同步的同步数据的数据量。其中,期望的同步时长可以是固定值,或者期望的同步时长可以与通信连接的等级有关,或者期望的同步时长可以与被同步的文件的类型有关。
例如,通信连接的等级越高(值越小),期望的同步时长可以越低。
又例如,用户高频次修改的文件的期望的同步时长可以低于用户低频次修改的文件的期望的同步时长。
可选的,在本申请一些实施例中,考虑到预测的同步速率必然存在一些误差,则可以依据通信连接的等级直接确定同步数据的数据量。例如,当通信连接为1级时,客户端可以直接确定同步数据的数据量为50KB,当通信连接为2级时,客户端可以直接确定同步数据的数据量为45KB等。
下面结合图6所示的内容,示例性的介绍客户端确定待同步文件集合的方法。
图6为本申请实施例提供的确定同步的文件数量的方法的一个示例性示意图。
如图6所示,确定同步的文件的数量的方法可以包括:
S601:客户端初始化同步队列。
具体的,在步骤S305中,客户端已经确定了不同文件的同步优先级。客户端可以通过多种数据结构方式如队列、数组、最小堆初始化同步队列,其中优先级高的文件可以被客户端优先确定。
S602:客户端确定一次同步的同步数据的数据量。
具体的,客户端可以基于同步速率,确定一次同步的同步数据的数据量大小。
S603:客户端将同步优先级最高的文件加入待同步文件集合。
具体的,客户端从同步队列中依次提取优先级最高的文件,并将该优先级最高的文件加入待同步文件集合,并且更新同步队列。
S604:待同步文件集合中的文件的同步数据的数据量的和小于等于一次同步的同步数据的数据量。
具体的,客户端判断待同步中的文件的脏数据的和是否小于一次同步的同步数据的数据量。若是,则执行步骤S603;若否,则执行步骤S605。
值得说明的是,若后续步骤中,客户端同步时发送的同步数据为写操作,则客户端判断 待同步中的文件的写操作的和是否小于同步数据的数据量。
S605:将最后加入的文件从待同步文件集合中移除。
具体的,待同步文件集合中的同步数据的数据量和大于一次同步的同步数据的数据量时,客户端将最后加入的文件从待同步文件集合中移除。
可选的,在本申请一些实施例中,考虑到同步数据的数据量存在一定误差,客户端也可以不将最后加入的文件从待同步文件集合中移除。
下面结合图7所示的内容,具体的示例性的介绍图6中确定待同步文件集合的方法。
图7为本申请实施例提供的确定待同步文件集合方法的一个示例性示意图。
如图7所示,客户端可以使用最小堆确定待同步文件集合,最小堆中每个堆节点的值为不同文件的同步优先级。
客户端可以不断选择最小堆顶的根节点,直到待同步文件集合的数据和大于一次同步的同步数据的数据量。或者,客户端可以不断选择最小堆顶的根节点对应的文件的同步数据进行同步,直到下一次增加同步的文件的同步数据后,待同步文件集合数据的和第一次大于一次同步的同步数据的数据量。
例如,客户端确定一次同步的同步数据的数据量为45KB。其中,同步优先级为-5的文件的同步数据的数据量为15KB,同步优先级为-2的文件的同步数据的数据量为28KB,同步优先级为12的文件的同步数据的数据量为30KB,同步优先级为16的文件的同步数据的数据量为35KB。
在该情况下,客户端可以选择同步优先级为-5的文件1、同步优先级为-2的文件2、同步优先级为-28的文件作为本次同步的文件3,即文件1、文件2、文件3构成了待同步文件集合;或者,客户端可以选择同步优先级为-5的文件1、同步优先级为-2的文件作为本次同步的文件2,即文件1和文件2构成待同步文件集合。
S307:客户端向服务端发送同步请求以同步。
具体的,客户端在确定了待同步文件集合后,可以向服务端按照同步优先级的顺序发送待同步文件集合中的文件的同步数据。
其中,客户端可以周期性的与服务端进行同步。例如,同步周期可以是预配置的固定的阈值,或者同步周期可以是根据步骤S306中客户端确定的同步速率、通信连接的等级变化的。例如,当同步速率较高时或当通信连接的等级较高时,可以降低同步周期,增加同步的频率。例如,通信连接的等级等于1时,同步周期为0.02s;通信连接的等级在2-4时,同步周期为0.1s;通信连接的等级在5-7时,同步周期为0.3s。
其中,客户端可以在缓存中的数据量占据缓存一定比例后,进行同步。例如,当源文件的副本占据缓存的80%时,客户端进行同步。
其中,客户端在同步多个文件的过程中,对单个文件的同步可以是回写机制。回写机制的内容可以参考图1B、图1C、图1D、图1E、图1F对应的文字描述,此处不再赘述。
可选的,在本申请一些实施例中,客户端还可以配置有超时机制以应对网络抖动。例如,若同步的同步时长超过预设值的阈值,暂停同步,并发送心跳检测包测试客户端与服务端之通信连接的数据传输速率。
图8为本申请实施例提供的超时机制的一个示例性示意图。
当客户端在同步过程中,基于客户端与服务端之间通信连接遵守的协议,客户端可以确 定同步时长。例如,客户端与服务端之间的通信连接遵守TCP协议,则客户端发出承载有文件的脏数据的IP报文,进而根据客户端接收到服务端的ACK报文的时间差确定同步时长。
如图8所示,当同步时长大于同步时长阈值时,同步超时。此时,客户端暂停同步,即暂停向服务端发送数据,并且,向服务端发送心跳检测包。其中,心跳检测也可以称为断线检测。若客户端确定通信连接恢复,则继续同步;若通信连接未恢复,则重新发送心跳检测包。
再次,介绍客户端实施本申请实施例提供的多文件同步方法的场景。
其一,介绍本申请实施例提供的多文件同步方法可以降低客户端缓存中同步的平均同步时长。
客户端上的缓存中有N个源文件的副本。其中N为大于2的整数;其中该N个源文件的副本的同步数据的同步时间(同步时间可以不等于同步时长,同步时间=文件或文件的脏数据量/同步速率)分别为t 1、t 2、…、t N
若单文件同步方法同步的文件的顺序为从文件1至文件N,该N个源文件的副本的同步数据的同步时长分别为M 1,M 2,…,M N
则第i个源文件的副本的同步时长为:
Figure PCTCN2022106900-appb-000013
则,单文件同步方法的平均同步时长为
Figure PCTCN2022106900-appb-000014
本申请实施例提供的多文件同步方法,若基于文件的同步数据的数据量确定文件的同步优先级,文件的同步数据的数据量越多,文件的同步优先级越低。
客户端根据确定的文件的同步优先级确定文件的同步顺序为:文件N至文件1。
则第i个源文件的副本的同步时长为:
Figure PCTCN2022106900-appb-000015
则,多文件同步方法的平均同步时长为
Figure PCTCN2022106900-appb-000016
由于,当客户端与服务端之间的通信连接的传输速率不变或变化不大时,同步数据的数据量小的文件的同步时长必然小于同步数据的数据量的文件的同步时长。则,T′ avg≤T avg
并且,在降低同步时长的基础上,本申请实施例提供的多文件同步方法,不会优先同步老化程度低的文件,避免了客户端总是优先同步新产生的同步数据导致而延后同步老化程度较高的文件导致的客户端与数据段不一致的情况,提升了用户体验。
其二,结合图2D、图9A所示的内容介绍本申请实施例提供的多文件同步方法可以降低客户端缓存中同步的平均同步时长。
如图2D所示,文件1的同步数据的数据量为1020KB、文件2的同步数据的数据量为500KB、文件3的同步数据的数据量为460KB。
客户端可以确定文件1的同步优先级最低,文件2的同步优先级次低,文件3的同步优先级,进而基于确定的同步优先级依次同步文件3、文件2、文件1。
图9A、图9B为本申请实施例提供的多文件同步场景的一个示例性示意图。
如图9A所示,客户端在第0秒开始向服务端依次同步文件1、文件2、文件3。客户端在第2.3秒时将文件3的同步数据全部发送出去,完成文件3的同步;客户端在第2.3开始传输文件2的同步数据,在第4.8秒时,客户端将文件2的同步数据全部发送出去,完成文件2的同步;客户端在第4.8秒开始传输文件2的同步数据,在第9.9秒时,客户端将文件3的同步数据全部发送出去,完成文件3的同步。
很明显的,图2D所示的单文件同步方法同步三个文件时,平均同步时长为(9.9+7.6+5.1)/3=7.53秒;本申请实施例提供的多文件同步方法同步三个文件时,平均同步时长为(9.9+4.8+2.3)/3=5.67秒。
本申请实施例提供的多文件同步方法还考虑了老化程度。如图9B所示,客户端上的缓存存有文件1、文件2、文件3、文件4、文件5和文件6。文件1的同步数据的数据量为1020KB,文件2的同步数据的数据量为500KB,文件3的同步数据的数据量为460KB,文件4的同步数据的数据量为860KB,文件5的同步数据的数据量为350KB,文件6的同步数据的数据量为860KB。
客户端实施本申请的多文件同步方法时,可以依据
Figure PCTCN2022106900-appb-000017
确定文件的同步优先级。其中T 3等于10。
客户端在实施本申请的多文件同步方法后,优先级从低到高(先同步到后同步)分别为:文件1、文件5、文件3、文件2、文件6、文件4。其中,文件6与文件4的同步数据的数据量相同,且老化程度均低于老化阈值,客户端可以先同步同步数据量小的文件6,后同步数据量大的文件4。
值得说明的是,还可以根据步骤S305中涉及的其他方式确定文件的同步优先级。
再次,介绍本申请实施例提供的客户端、服务端的软件结构、硬件结构。
客户端、服务端均可以为下文中的电子设备100。
图10为本申请实施例提供的电子设备100的硬件结构的一个示例性示意图。
电子设备100可以是手机、平板电脑、桌面型计算机、膝上型计算机、手持计算机、笔记本电脑、超级移动个人计算机(ultra-mobile personal computer,UMPC)、上网本,以及蜂窝电话、个人数字助理(personal digital assistant,PDA)、增强现实(augmented reality,AR)设备、虚拟现实(virtual reality,VR)设备、人工智能(artificial intelligence,AI)设备、可穿戴式设备、车载设备、智能家居设备和/或智慧城市设备,本申请实施例对该电子设备的具体类型不作特殊限制。
电子设备100可以包括处理器110,外部存储器接口120,内部存储器121,通用串行总线(universal serial bus,USB)接口130,充电管理模块140,电源管理模块141,电池142,天线1,天线2,移动通信模块150,无线通信模块160,音频模块170,扬声器170A,受话器170B,麦克风170C,耳机接口170D,传感器模块180,按键190,马达191,指示器192,摄像头193,显示屏194,以及用户标识模块(subscriber identification module,SIM)卡接口195等。其中传感器模块180可以包括压力传感器180A,陀螺仪传感器180B,气压传感器180C,磁传感器180D,加速度传感器180E,距离传感器180F,接近光传感器180G,指纹传感器180H,温度传感器180J,触摸传感器180K,环境光传感器180L,骨传导传感器180M等。
可以理解的是,本发明实施例示意的结构并不构成对电子设备100的具体限定。在本申请另一些实施例中,电子设备100可以包括比图示更多或更少的部件,或者组合某些部件,或者拆分某些部件,或者不同的部件布置。图示的部件可以以硬件,软件或软件和硬件的组合实现。
处理器110可以包括一个或多个处理单元,例如:处理器110可以包括应用处理器 (application processor,AP),调制解调处理器,图形处理器(graphics processing unit,GPU),图像信号处理器(image signal processor,ISP),控制器,视频编解码器,数字信号处理器(digital signal processor,DSP),基带处理器,和/或神经网络处理器(neural-network processing unit,NPU)等。其中,不同的处理单元可以是独立的器件,也可以集成在一个或多个处理器中。
控制器可以根据指令操作码和时序信号,产生操作控制信号,完成取指令和执行指令的控制。
处理器110中还可以设置存储器,用于存储指令和数据。在一些实施例中,处理器110中的存储器为高速缓冲存储器。该存储器可以保存处理器110刚用过或循环使用的指令或数据。如果处理器110需要再次使用该指令或数据,可从所述存储器中直接调用。避免了重复存取,减少了处理器110的等待时间,因而提高了系统的效率。
在一些实施例中,处理器110可以包括一个或多个接口。接口可以包括集成电路(inter-integrated circuit,I2C)接口,集成电路内置音频(inter-integrated circuit sound,I2S)接口,脉冲编码调制(pulse code modulation,PCM)接口,通用异步收发传输器(universal asynchronous receiver/transmitter,UART)接口,移动产业处理器接口(mobile industry processor interface,MIPI),通用输入输出(general-purpose input/output,GPIO)接口,用户标识模块(subscriber identity module,SIM)接口,和/或通用串行总线(universal serial bus,USB)接口等。
I2C接口是一种双向同步串行总线,包括一根串行数据线(serial data line,SDA)和一根串行时钟线(derail clock line,SCL)。在一些实施例中,处理器110可以包含多组I2C总线。处理器110可以通过不同的I2C总线接口分别耦合触摸传感器180K,充电器,闪光灯,摄像头193等。例如:处理器110可以通过I2C接口耦合触摸传感器180K,使处理器110与触摸传感器180K通过I2C总线接口通信,实现电子设备100的触摸功能。
I2S接口可以用于音频通信。在一些实施例中,处理器110可以包含多组I2S总线。处理器110可以通过I2S总线与音频模块170耦合,实现处理器110与音频模块170之间的通信。在一些实施例中,音频模块170可以通过I2S接口向无线通信模块160传递音频信号,实现通过蓝牙耳机接听电话的功能。
PCM接口也可以用于音频通信,将模拟信号抽样,量化和编码。在一些实施例中,音频模块170与无线通信模块160可以通过PCM总线接口耦合。在一些实施例中,音频模块170也可以通过PCM接口向无线通信模块160传递音频信号,实现通过蓝牙耳机接听电话的功能。所述I2S接口和所述PCM接口都可以用于音频通信。
UART接口是一种通用串行数据总线,用于异步通信。该总线可以为双向通信总线。它将要传输的数据在串行通信与并行通信之间转换。在一些实施例中,UART接口通常被用于连接处理器110与无线通信模块160。例如:处理器110通过UART接口与无线通信模块160中的蓝牙模块通信,实现蓝牙功能。在一些实施例中,音频模块170可以通过UART接口向无线通信模块160传递音频信号,实现通过蓝牙耳机播放音乐的功能。
MIPI接口可以被用于连接处理器110与显示屏194,摄像头193等外围器件。MIPI接口包括摄像头串行接口(camera serial interface,CSI),显示屏串行接口(display serial interface,DSI)等。在一些实施例中,处理器110和摄像头193通过CSI接口通信,实现电子设备100的拍摄功能。处理器110和显示屏194通过DSI接口通信,实现电子设备100的显示功能。
GPIO接口可以通过软件配置。GPIO接口可以被配置为控制信号,也可被配置为数据信号。在一些实施例中,GPIO接口可以用于连接处理器110与摄像头193,显示屏194,无线通信模块160,音频模块170,传感器模块180等。GPIO接口还可以被配置为I2C接口,I2S 接口,UART接口,MIPI接口等。
USB接口130是符合USB标准规范的接口,具体可以是Mini USB接口,Micro USB接口,USB Type C接口等。USB接口130可以用于连接充电器为电子设备100充电,也可以用于电子设备100与外围设备之间传输数据。也可以用于连接耳机,通过耳机播放音频。该接口还可以用于连接其他电子设备,例如AR设备等。
可以理解的是,本发明实施例示意的各模块间的接口连接关系,只是示意性说明,并不构成对电子设备100的结构限定。在本申请另一些实施例中,电子设备100也可以采用上述实施例中不同的接口连接方式,或多种接口连接方式的组合。
充电管理模块140用于从充电器接收充电输入。其中,充电器可以是无线充电器,也可以是有线充电器。在一些有线充电的实施例中,充电管理模块140可以通过USB接口130接收有线充电器的充电输入。在一些无线充电的实施例中,充电管理模块140可以通过电子设备100的无线充电线圈接收无线充电输入。充电管理模块140为电池142充电的同时,还可以通过电源管理模块141为电子设备供电。
电源管理模块141用于连接电池142,充电管理模块140与处理器110。电源管理模块141接收电池142和/或充电管理模块140的输入,为处理器110,内部存储器121,显示屏194,摄像头193,和无线通信模块160等供电。电源管理模块141还可以用于监测电池容量,电池循环次数,电池健康状态(漏电,阻抗)等参数。在其他一些实施例中,电源管理模块141也可以设置于处理器110中。在另一些实施例中,电源管理模块141和充电管理模块140也可以设置于同一个器件中。
电子设备100的无线通信功能可以通过天线1,天线2,移动通信模块150,无线通信模块160,调制解调处理器以及基带处理器等实现。
天线1和天线2用于发射和接收电磁波信号。电子设备100中的每个天线可用于覆盖单个或多个通信频带。不同的天线还可以复用,以提高天线的利用率。例如:可以将天线1复用为无线局域网的分集天线。在另外一些实施例中,天线可以和调谐开关结合使用。
移动通信模块150可以提供应用在电子设备100上的包括2G/3G/4G/5G等无线通信的解决方案。移动通信模块150可以包括至少一个滤波器,开关,功率放大器,低噪声放大器(low noise amplifier,LNA)等。移动通信模块150可以由天线1接收电磁波,并对接收的电磁波进行滤波,放大等处理,传送至调制解调处理器进行解调。移动通信模块150还可以对经调制解调处理器调制后的信号放大,经天线1转为电磁波辐射出去。在一些实施例中,移动通信模块150的至少部分功能模块可以被设置于处理器110中。在一些实施例中,移动通信模块150的至少部分功能模块可以与处理器110的至少部分模块被设置在同一个器件中。
调制解调处理器可以包括调制器和解调器。其中,调制器用于将待发送的低频基带信号调制成中高频信号。解调器用于将接收的电磁波信号解调为低频基带信号。随后解调器将解调得到的低频基带信号传送至基带处理器处理。低频基带信号经基带处理器处理后,被传递给应用处理器。应用处理器通过音频设备(不限于扬声器170A,受话器170B等)输出声音信号,或通过显示屏194显示图像或视频。在一些实施例中,调制解调处理器可以是独立的器件。在另一些实施例中,调制解调处理器可以独立于处理器110,与移动通信模块150或其他功能模块设置在同一个器件中。
无线通信模块160可以提供应用在电子设备100上的包括无线局域网(wireless local area networks,WLAN)(如无线保真(wireless fidelity,Wi-Fi)网络),蓝牙(bluetooth,BT),全球导航卫星系统(global navigation satellite system,GNSS),调频(frequency modulation,FM),近距 离无线通信技术(near field communication,NFC),红外技术(infrared,IR)等无线通信的解决方案。无线通信模块160可以是集成至少一个通信处理模块的一个或多个器件。无线通信模块160经由天线2接收电磁波,将电磁波信号调频以及滤波处理,将处理后的信号发送到处理器110。无线通信模块160还可以从处理器110接收待发送的信号,对其进行调频,放大,经天线2转为电磁波辐射出去。
在一些实施例中,电子设备100的天线1和移动通信模块150耦合,天线2和无线通信模块160耦合,使得电子设备100可以通过无线通信技术与网络以及其他设备通信。所述无线通信技术可以包括全球移动通讯系统(global system for mobile communications,GSM),通用分组无线服务(general packet radio service,GPRS),码分多址接入(code division multiple access,CDMA),宽带码分多址(wideband code division multiple access,WCDMA),时分码分多址(time-division code division multiple access,TD-SCDMA),长期演进(long term evolution,LTE),BT,GNSS,WLAN,NFC,FM,和/或IR技术等。所述GNSS可以包括全球卫星定位系统(global positioning system,GPS),全球导航卫星系统(global navigation satellite system,GLONASS),北斗卫星导航系统(beidou navigation satellite system,BDS),准天顶卫星系统(quasi-zenith satellite system,QZSS)和/或星基增强系统(satellite based augmentation systems,SBAS)。
电子设备100通过GPU,显示屏194,以及应用处理器等实现显示功能。GPU为图像处理的微处理器,连接显示屏194和应用处理器。GPU用于执行数学和几何计算,用于图形渲染。处理器110可包括一个或多个GPU,其执行程序指令以生成或改变显示信息。
显示屏194用于显示图像,视频等。显示屏194包括显示面板。显示面板可以采用液晶显示屏(liquid crystal display,LCD),有机发光二极管(organic light-emitting diode,OLED),有源矩阵有机发光二极体或主动矩阵有机发光二极体(active-matrix organic light emitting diode的,AMOLED),柔性发光二极管(flex light-emitting diode,FLED),Miniled,MicroLed,Micro-oLed,量子点发光二极管(quantum dot light emitting diodes,QLED)等。在一些实施例中,电子设备100可以包括1个或N个显示屏194,N为大于1的正整数。
电子设备100可以通过ISP,摄像头193,视频编解码器,GPU,显示屏194以及应用处理器等实现拍摄功能。
ISP用于处理摄像头193反馈的数据。例如,拍照时,打开快门,光线通过镜头被传递到摄像头感光元件上,光信号转换为电信号,摄像头感光元件将所述电信号传递给ISP处理,转化为肉眼可见的图像。ISP还可以对图像的噪点,亮度,肤色进行算法优化。ISP还可以对拍摄场景的曝光,色温等参数优化。在一些实施例中,ISP可以设置在摄像头193中。
摄像头193用于捕获静态图像或视频。物体通过镜头生成光学图像投射到感光元件。感光元件可以是电荷耦合器件(charge coupled device,CCD)或互补金属氧化物半导体(complementary metal-oxide-semiconductor,CMOS)光电晶体管。感光元件把光信号转换成电信号,之后将电信号传递给ISP转换成数字图像信号。ISP将数字图像信号输出到DSP加工处理。DSP将数字图像信号转换成标准的RGB,YUV等格式的图像信号。在一些实施例中,电子设备100可以包括1个或N个摄像头193,N为大于1的正整数。
数字信号处理器用于处理数字信号,除了可以处理数字图像信号,还可以处理其他数字信号。例如,当电子设备100在频点选择时,数字信号处理器用于对频点能量进行傅里叶变换等。
视频编解码器用于对数字视频压缩或解压缩。电子设备100可以支持一种或多种视频编 解码器。这样,电子设备100可以播放或录制多种编码格式的视频,例如:动态图像专家组(moving picture experts group,MPEG)1,MPEG2,MPEG3,MPEG4等。
NPU为神经网络(neural-network,NN)计算处理器,通过借鉴生物神经网络结构,例如借鉴人脑神经元之间传递模式,对输入信息快速处理,还可以不断的自学习。通过NPU可以实现电子设备100的智能认知等应用,例如:图像识别,人脸识别,语音识别,文本理解等。
内部存储器121可以包括一个或多个随机存取存储器(random access memory,RAM)和一个或多个非易失性存储器(non-volatile memory,NVM)。
随机存取存储器可以包括静态随机存储器(static random-access memory,SRAM)、动态随机存储器(dynamic random access memory,DRAM)、同步动态随机存储器(synchronous dynamic random access memory,SDRAM)、双倍资料率同步动态随机存取存储器(double data rate synchronous dynamic random access memory,DDR SDRAM,例如第五代DDR SDRAM一般称为DDR5SDRAM)等;
其中,客户端的缓存可以位于随机存取存储器中。
非易失性存储器可以包括磁盘存储器件、快闪存储器(flash memory)。
快闪存储器按照运作原理划分可以包括NOR FLASH、NAND FLASH、3D NAND FLASH等,按照存储单元电位阶数划分可以包括单阶存储单元(single-level cell,SLC)、多阶存储单元(multi-level cell,MLC)、三阶储存单元(triple-level cell,TLC)、四阶储存单元(quad-level cell,QLC)等,按照存储规范划分可以包括通用闪存存储(英文:universal flash storage,UFS)、嵌入式多媒体存储卡(embedded multi media Card,eMMC)等。
随机存取存储器可以由处理器110直接进行读写,可以用于存储操作系统或其他正在运行中的程序的可执行程序(例如机器指令),还可以用于存储用户及应用程序的数据等。
非易失性存储器也可以存储可执行程序和存储用户及应用程序的数据等,可以提前加载到随机存取存储器中,用于处理器110直接进行读写。
外部存储器接口120可以用于连接外部的非易失性存储器,实现扩展电子设备100的存储能力。外部的非易失性存储器通过外部存储器接口120与处理器110通信,实现数据存储功能。例如将音乐,视频等文件保存在外部的非易失性存储器中。
电子设备100可以通过音频模块170,扬声器170A,受话器170B,麦克风170C,耳机接口170D,以及应用处理器等实现音频功能。例如音乐播放,录音等。
音频模块170用于将数字音频信息转换成模拟音频信号输出,也用于将模拟音频输入转换为数字音频信号。音频模块170还可以用于对音频信号编码和解码。在一些实施例中,音频模块170可以设置于处理器110中,或将音频模块170的部分功能模块设置于处理器110中。
扬声器170A,也称“喇叭”,用于将音频电信号转换为声音信号。电子设备100可以通过扬声器170A收听音乐,或收听免提通话。
受话器170B,也称“听筒”,用于将音频电信号转换成声音信号。当电子设备100接听电话或语音信息时,可以通过将受话器170B靠近人耳接听语音。
麦克风170C,也称“话筒”,“传声器”,用于将声音信号转换为电信号。当拨打电话或发送语音信息时,用户可以通过人嘴靠近麦克风170C发声,将声音信号输入到麦克风170C。电子设备100可以设置至少一个麦克风170C。在另一些实施例中,电子设备100可以设置两个麦克风170C,除了采集声音信号,还可以实现降噪功能。在另一些实施例中,电子设备100还可以设置三个,四个或更多麦克风170C,实现采集声音信号,降噪,还可以识别声音 来源,实现定向录音功能等。
耳机接口170D用于连接有线耳机。耳机接口170D可以是USB接口130,也可以是3.5mm的开放移动电子设备平台(open mobile terminal platform,OMTP)标准接口,美国蜂窝电信工业协会(cellular telecommunications industry association of the USA,CTIA)标准接口。
压力传感器180A用于感受压力信号,可以将压力信号转换成电信号。在一些实施例中,压力传感器180A可以设置于显示屏194。压力传感器180A的种类很多,如电阻式压力传感器,电感式压力传感器,电容式压力传感器等。电容式压力传感器可以是包括至少两个具有导电材料的平行板。当有力作用于压力传感器180A,电极之间的电容改变。电子设备100根据电容的变化确定压力的强度。当有触摸操作作用于显示屏194,电子设备100根据压力传感器180A检测所述触摸操作强度。电子设备100也可以根据压力传感器180A的检测信号计算触摸的位置。在一些实施例中,作用于相同触摸位置,但不同触摸操作强度的触摸操作,可以对应不同的操作指令。例如:当有触摸操作强度小于第一压力阈值的触摸操作作用于短消息应用图标时,执行查看短消息的指令。当有触摸操作强度大于或等于第一压力阈值的触摸操作作用于短消息应用图标时,执行新建短消息的指令。
陀螺仪传感器180B可以用于确定电子设备100的运动姿态。在一些实施例中,可以通过陀螺仪传感器180B确定电子设备100围绕三个轴(即,x,y和z轴)的角速度。陀螺仪传感器180B可以用于拍摄防抖。示例性的,当按下快门,陀螺仪传感器180B检测电子设备100抖动的角度,根据角度计算出镜头模组需要补偿的距离,让镜头通过反向运动抵消电子设备100的抖动,实现防抖。陀螺仪传感器180B还可以用于导航,体感游戏场景。
气压传感器180C用于测量气压。在一些实施例中,电子设备100通过气压传感器180C测得的气压值计算海拔高度,辅助定位和导航。
磁传感器180D包括霍尔传感器。电子设备100可以利用磁传感器180D检测翻盖皮套的开合。在一些实施例中,当电子设备100是翻盖机时,电子设备100可以根据磁传感器180D检测翻盖的开合。进而根据检测到的皮套的开合状态或翻盖的开合状态,设置翻盖自动解锁等特性。
加速度传感器180E可检测电子设备100在各个方向上(一般为三轴)加速度的大小。当电子设备100静止时可检测出重力的大小及方向。还可以用于识别电子设备姿态,应用于横竖屏切换,计步器等应用。
距离传感器180F,用于测量距离。电子设备100可以通过红外或激光测量距离。在一些实施例中,拍摄场景,电子设备100可以利用距离传感器180F测距以实现快速对焦。
接近光传感器180G可以包括例如发光二极管(LED)和光检测器,例如光电二极管。发光二极管可以是红外发光二极管。电子设备100通过发光二极管向外发射红外光。电子设备100使用光电二极管检测来自附近物体的红外反射光。当检测到充分的反射光时,可以确定电子设备100附近有物体。当检测到不充分的反射光时,电子设备100可以确定电子设备100附近没有物体。电子设备100可以利用接近光传感器180G检测用户手持电子设备100贴近耳朵通话,以便自动熄灭屏幕达到省电的目的。接近光传感器180G也可用于皮套模式,口袋模式自动解锁与锁屏。
环境光传感器180L用于感知环境光亮度。电子设备100可以根据感知的环境光亮度自适应调节显示屏194亮度。环境光传感器180L也可用于拍照时自动调节白平衡。环境光传感器180L还可以与接近光传感器180G配合,检测电子设备100是否在口袋里,以防误触。
指纹传感器180H用于采集指纹。电子设备100可以利用采集的指纹特性实现指纹解锁, 访问应用锁,指纹拍照,指纹接听来电等。
温度传感器180J用于检测温度。在一些实施例中,电子设备100利用温度传感器180J检测的温度,执行温度处理策略。例如,当温度传感器180J上报的温度超过阈值,电子设备100执行降低位于温度传感器180J附近的处理器的性能,以便降低功耗实施热保护。在另一些实施例中,当温度低于另一阈值时,电子设备100对电池142加热,以避免低温导致电子设备100异常关机。在其他一些实施例中,当温度低于又一阈值时,电子设备100对电池142的输出电压执行升压,以避免低温导致的异常关机。
触摸传感器180K,也称“触控器件”。触摸传感器180K可以设置于显示屏194,由触摸传感器180K与显示屏194组成触摸屏,也称“触控屏”。触摸传感器180K用于检测作用于其上或附近的触摸操作。触摸传感器可以将检测到的触摸操作传递给应用处理器,以确定触摸事件类型。可以通过显示屏194提供与触摸操作相关的视觉输出。在另一些实施例中,触摸传感器180K也可以设置于电子设备100的表面,与显示屏194所处的位置不同。
骨传导传感器180M可以获取振动信号。在一些实施例中,骨传导传感器180M可以获取人体声部振动骨块的振动信号。骨传导传感器180M也可以接触人体脉搏,接收血压跳动信号。在一些实施例中,骨传导传感器180M也可以设置于耳机中,结合成骨传导耳机。音频模块170可以基于所述骨传导传感器180M获取的声部振动骨块的振动信号,解析出语音信号,实现语音功能。应用处理器可以基于所述骨传导传感器180M获取的血压跳动信号解析心率信息,实现心率检测功能。
按键190包括开机键,音量键等。按键190可以是机械按键。也可以是触摸式按键。电子设备100可以接收按键输入,产生与电子设备100的用户设置以及功能控制有关的键信号输入。
马达191可以产生振动提示。马达191可以用于来电振动提示,也可以用于触摸振动反馈。例如,作用于不同应用(例如拍照,音频播放等)的触摸操作,可以对应不同的振动反馈效果。作用于显示屏194不同区域的触摸操作,马达191也可对应不同的振动反馈效果。不同的应用场景(例如:时间提醒,接收信息,闹钟,游戏等)也可以对应不同的振动反馈效果。触摸振动反馈效果还可以支持自定义。
指示器192可以是指示灯,可以用于指示充电状态,电量变化,也可以用于指示消息,未接来电,通知等。
SIM卡接口195用于连接SIM卡。SIM卡可以通过插入SIM卡接口195,或从SIM卡接口195拔出,实现和电子设备100的接触和分离。电子设备100可以支持1个或N个SIM卡接口,N为大于1的正整数。SIM卡接口195可以支持Nano SIM卡,Micro SIM卡,SIM卡等。同一个SIM卡接口195可以同时插入多张卡。所述多张卡的类型可以相同,也可以不同。SIM卡接口195也可以兼容不同类型的SIM卡。SIM卡接口195也可以兼容外部存储卡。电子设备100通过SIM卡和网络交互,实现通话以及数据通信等功能。在一些实施例中,电子设备100采用eSIM,即:嵌入式SIM卡。eSIM卡可以嵌在电子设备100中,不能和电子设备100分离。
电子设备100的软件系统可以采用分层架构,事件驱动架构,微核架构,微服务架构,或云架构。本发明实施例以分层架构的Android系统为例,示例性说明电子设备100的软件结构。
图11为本申请实施例提供的电子设备100的软件结构的一个示例性示意图。
分层架构将软件分成若干个层,每一层都有清晰的角色和分工。层与层之间通过软件接口通信。在一些实施例中,将Android系统分为四层,从上至下分别为应用程序层,应用程序框架层,安卓运行时(Android runtime)和系统库,以及内核层。
应用程序层可以包括一系列应用程序包。
如图11所示,应用程序包可以包括相机,图库,日历,通话,地图,导航,WLAN,蓝牙,音乐,视频,短信息等应用程序。
其中,应用程序运行过程从各自的服务器上获取的数据,均可以为本申请实施例中的同步数据。其中,一个应用程序可以与一个或多个源文件的副本对应。
应用程序框架层为应用程序层的应用程序提供应用编程接口(application programming interface,API)和编程框架。应用程序框架层包括一些预先定义的函数。
如图11所示,应用程序框架层可以包括窗口管理器,内容提供器,视图系统,电话管理器,资源管理器,通知管理器等。
窗口管理器用于管理窗口程序。窗口管理器可以获取显示屏大小,判断是否有状态栏,锁定屏幕,截取屏幕等。
内容提供器用来存放和获取数据,并使这些数据可以被应用程序访问。所述数据可以包括视频,图像,音频,拨打和接听的电话,浏览历史和书签,电话簿等。
视图系统包括可视控件,例如显示文字的控件,显示图片的控件等。视图系统可用于构建应用程序。显示界面可以由一个或多个视图组成的。例如,包括短信通知图标的显示界面,可以包括显示文字的视图以及显示图片的视图。
电话管理器用于提供电子设备100的通信功能。例如通话状态的管理(包括接通,挂断等)。
资源管理器为应用程序提供各种资源,比如本地化字符串,图标,图片,布局文件,视频文件等等。
通知管理器使应用程序可以在状态栏中显示通知信息,可以用于传达告知类型的消息,可以短暂停留后自动消失,无需用户交互。比如通知管理器被用于告知下载完成,消息提醒等。通知管理器还可以是以图表或者滚动条文本形式出现在系统顶部状态栏的通知,例如后台运行的应用程序的通知,还可以是以对话窗口形式出现在屏幕上的通知。例如在状态栏提示文本信息,发出提示音,电子设备振动,指示灯闪烁等。
Android Runtime包括核心库和虚拟机。Android runtime负责安卓系统的调度和管理。
核心库包含两部分:一部分是java语言需要调用的功能函数,另一部分是安卓的核心库。
应用程序层和应用程序框架层运行在虚拟机中。虚拟机将应用程序层和应用程序框架层的java文件执行为二进制文件。虚拟机用于执行对象生命周期的管理,堆栈管理,线程管理,安全和异常的管理,以及垃圾回收等功能。
系统库可以包括多个功能模块。例如:表面管理器(surface manager),媒体库(Media Libraries),三维图形处理库(例如:OpenGL ES),2D图形引擎(例如:SGL)等。
表面管理器用于对显示子系统进行管理,并且为多个应用程序提供了2D和3D图层的融合。
媒体库支持多种常用的音频,视频格式回放和录制,以及静态图像文件等。媒体库可以支持多种音视频编码格式,例如:MPEG4,H.264,MP3,AAC,AMR,JPG,PNG等。
三维图形处理库用于实现三维图形绘图,图像渲染,合成,和图层处理等。
2D图形引擎是2D绘图的绘图引擎。
系统库还可以包括同步库。其中,同步库中提供一个或多个方法,使得电子设备100可 以执行本申请实施例提供的多文件同步方法。更具体的,电子设备上的任一个应用层的应用均可以调用同步库中的方法,进而同步该应用产生的同步数据。
内核层是硬件和软件之间的层。内核层至少包含显示驱动,摄像头驱动,音频驱动,传感器驱动。
图12为本申请实施例提供的电子设备100的另一个软件架构示意图。
如图12所示,电子设备100中包括多个功能模块,如:缓存管理模块、缓存调度模块、网络探测模块。
其中,缓存管理模块可以确定客户端上多个源文件的副本的同步信息。其中,同步信息可以包括:脏页所在的位置、脏页数、文件是否为脏、脏数据占文件数据的比例、最近修改时刻、最近同步时刻、写操作的数据量。缓存管理模块确定同步信息的方法具体的可以参考上文中图3中步骤S304中对应的文字描述,此处不再赘述。
其中,网络探测模块可以确定客户端与服务端之间的通信连接的同步速率。网络探测模块确定客户端与服务端之间的通信连接的同步速率的方法具体的可以参考上文中图3中步骤S306中的文字描述。
其中,缓存调度模块可以确定客户端上源文件的副本的同步优先级,缓存调度模块还可以确定一次同步的文件的数量。其中,缓存调度模块接收缓存管理模块确定的同步信息以及接收网络探测模块确定的同步速率。缓存调度模块确定客户端上源文件的副本的同步优先级的方法具体的可以参考上文中图3中步骤S306中的文字描述。
上述实施例中所用,根据上下文,术语“当…时”可以被解释为意思是“如果…”或“在…后”或“响应于确定…”或“响应于检测到…”。类似地,根据上下文,短语“在确定…时”或“如果检测到(所陈述的条件或事件)”可以被解释为意思是“如果确定…”或“响应于确定…”或“在检测到(所陈述的条件或事件)时”或“响应于检测到(所陈述的条件或事件)”。
在上述实施例中,可以全部或部分地通过软件、硬件、固件或者其任意组合来实现。当使用软件实现时,可以全部或部分地以计算机程序产品的形式实现。该计算机程序产品包括一个或多个计算机指令。在计算机上加载和执行该计算机程序指令时,全部或部分地产生按照本申请实施例该的流程或功能。该计算机可以是通用计算机、专用计算机、计算机网络、或者其他可编程装置。该计算机指令可以存储在计算机可读存储介质中,或者从一个计算机可读存储介质向另一个计算机可读存储介质传输,例如,该计算机指令可以从一个网站站点、计算机、服务器或数据中心通过有线(例如同轴电缆、光纤、数字用户线)或无线(例如红外、无线、微波等)方式向另一个网站站点、计算机、服务器或数据中心进行传输。该计算机可读存储介质可以是计算机能够存取的任何可用介质或者是包含一个或多个可用介质集成的服务器、数据中心等数据存储设备。该可用介质可以是磁性介质,(例如,软盘、硬盘、磁带)、光介质(例如DVD)、或者半导体介质(例如固态硬盘)等。
本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,该流程可以由计算机程序来指令相关的硬件完成,该程序可存储于计算机可读取存储介质中,该程序在执行时,可包括如上述各方法实施例的流程。而前述的存储介质包括:ROM或随机存储记忆体RAM、磁碟或者光盘等各种可存储程序代码的介质。

Claims (28)

  1. 一种多文件同步方法,其特征在于,包括:
    客户端从服务端获取多个文件副本;
    客户端确定所述多个文件副本的同步信息,所述同步信息包括同步数据的数据量和老化程度,所述老化程度对应于文件副本的未被同步时长;
    所述客户端基于所述多个文件副本的同步信息以及第一预设条件确定所述多个文件副本的同步优先级;
    所述第一预设条件包括:
    在所述文件副本的老化程度位于第一范围的情况下,所述文件副本的同步优先级与所述文件副本的老化程度有关;
    在所述文件副本的老化程度位于第二范围的情况下,所述文件副本的同步优先级与所述文件副本的同步数据的数据量有关。
  2. 根据权利要求1所述的方法,其特征在于,所述客户端基于所述多个文件副本的同步信息以及第一预设条件确定所述多个文件副本的同步优先级之后,还包括:
    所述客户端确定第一同步速率;
    所述客户端基于所述第一同步速率和所述多个文件副本的同步优先级确定待同步文件集合;
    所述客户端同步待同步文件集合中的文件副本。
  3. 根据权利要求2所述的方法,其特征在于,所述客户端确定第一同步速率,具体包括:
    所述客户端确定历史同步速率,所述历史同步速率与历史同步的同步数据的数据量和历史同步的同步时长有关;
    所述客户端基于所述历史同步速率确定所述第一同步速率。
  4. 根据权利要求2所述的方法,其特征在于,所述客户端基于所述第一同步速率和所述多个文件副本的优先级确定待同步文件集合,具体包括:
    所述客户端基于所述第一同步速率和预期同步时长确定同步数据的数据量;
    所述客户端基于所述同步数据的数据量和所述多个文件副本的同步优先级确定所述待同步文件集合。
  5. 根据权利要求1至4中任一项所述的方法,其特征在于,所述同步数据包括脏数据或写操作。
  6. 根据权利要求1至5中任一项所述的方法,其特征在于,所述客户端确定多个文件副本的同步信息,具体包括:
    所述客户端基于页的脏比特dirtybit确定多个文件副本的同步信息;
    或者,所述客户端基于写操作确定多个文件副本的同步信息。
  7. 根据权利要求1至6中任一项所述的方法,其特征在于,所述同步信息还包括:脏页的位置、脏页的数量、同步数据占文件的比例、最近修改时刻、最近同步时刻中的至少一种。
  8. 根据权利要求1至7中任一项所述的方法,其特征在于,
    所述第一范围的下限大于等于所述第一范围的上限;
    位于第一范围的文件副本的同步优先级小于所述位于第二范围的文件副本的同步优先级;
    同步优先级小的文件副本会被优先同步。
  9. 根据权利要求1至7中任一项所述的方法,其特征在于,
    所述第一范围的上限小于所述第一范围的下限;
    位于第一范围的文件副本的同步优先级大于所述位于第二范围的文件副本的同步优先级;
    同步优先级小的文件副本会被优先同步。
  10. 根据权利要求1至9中任一项所述的方法,其特征在于,
    所述多个文件副本包括第一文件副本、第二文件副本;
    所述第一文件副本的老化程度位于所述第一范围,所述第一文件副本的老化程度位于所述第一范围;
    在所述第一文件副本的老化程度小于所述第二文件副本的老化程度情况下,所述第一文件副本的同步优先级大于所述第二文件副本的同步优先级;
    在所述第一文件副本的老化程度大于所述第二文件副本的老化程度情况下,所述第一文件副本的优先级小于所述第二文件副本的同步优先级;
    同步优先级小的文件副本会被优先同步。
  11. 根据权利要求10所述的方法,其特征在于,
    在所述第一文件副本的老化程度等于所述第二文件副本的老化程度情况下,并且在所述第一文件副本的同步数据的数据量小于所述第二文件副本的同步数据的数据量情况下,所述第一文件副本的同步优先级小于所述第二文件副本的同步优先级;
    在所述第一文件副本的老化程度等于所述第二文件副本的老化程度情况下,并且在所述第一文件副本的同步数据的数据量大于所述第二文件副本的同步数据的数据量情况下,所述第一文件副本的同步优先级大于所述第二文件副本的同步优先级。
  12. 根据权利要求10所述的方法,其特征在于,在所述第一文件副本的老化程度等于所述第二文件副本的老化程度情况下,所述第一文件副本的同步优先级等于所述第二文件副本的同步优先级。
  13. 根据权利要求1至9中任一项所述的方法,其特征在于,
    所述多个文件副本包括第三文件副本、第四文件副本;
    所述第三文件副本的老化程度位于所述第二范围,所述第四文件副本的老化程度位于所述第二范围;
    在所述第三文件副本的同步数据的数据量小于所述第四文件副本的同步数据的数据量情况下,所述第三文件副本的同步优先级小于所述第四文件副本的同步优先级;
    在所述第三文件副本的同步数据的数据量大于所述第四文件副本的同步数据的数据量情况下,所述第三文件副本的同步优先级大于所述第四文件副本的同步优先级;
    同步优先级小的文件副本会被优先同步。
  14. 一种电子设备,其特征在于,所述电子设备包括:一个或多个处理器、存储器;
    所述存储器与所述一个或多个处理器耦合,所述存储器用于存储计算机程序代码,所述计算机程序代码包括计算机指令,所述一个或多个处理器调用所述计算机指令以使得所述电子设备执行:
    从服务端获取多个文件副本;
    确定所述多个文件副本的同步信息,所述同步信息包括同步数据的数据量和老化程度,所述老化程度对应于文件副本的未被同步时长;
    基于所述多个文件副本的同步信息以及第一预设条件确定所述多个文件副本的同步优先级;
    所述第一预设条件包括:
    在所述文件副本的老化程度位于第一范围的情况下,所述文件副本的同步优先级与所述文件副本的老化程度有关;
    在所述文件副本的老化程度位于第二范围的情况下,所述文件副本的同步优先级与所述文件副本的同步数据的数据量有关。
  15. 根据权利要求14所述的电子设备,其特征在于,所述一个或多个处理器还用于调用所述计算机指令以使得所述电子设备执行:
    确定第一同步速率;
    基于所述第一同步速率和所述多个文件副本的优先级确定待同步文件集合;
    同步待同步文件集合中的文件副本。
  16. 根据权利要求15所述的电子设备,其特征在于,所述一个或多个处理器具体用于调用所述计算机指令以使得所述电子设备执行:
    确定历史同步速率,所述历史同步速率与历史同步的同步数据的数据量和;历史同步的同步时长有关;
    基于所述历史同步速率确定所述第一同步速率。
  17. 根据权利要求15所述的电子设备,其特征在于,所述一个或多个处理器具体用于调用所述计算机指令以使得所述电子设备执行:
    基于所述第一同步速率和预期同步时长确定同步数据的数据量;
    基于所述同步数据的数据量和所述多个文件副本的同步优先级确定所述待同步文件集合。
  18. 根据权利要求14至17中任一项所述的电子设备,其特征在于,所述同步数据包括脏数据或写操作。
  19. 根据权利要求14至18中任一项所述的电子设备,其特征在于,所述一个或多个处理器具体用于调用所述计算机指令以使得所述电子设备执行:
    基于页的脏比特dirtybit确定多个文件副本的同步信息;
    或者,基于写操作确定多个文件副本的同步信息。
  20. 根据权利要求14至19中任一项所述的电子设备,其特征在于,所述同步信息还包括:脏页的位置、脏页的数量、同步数据占文件的比例、最近修改时刻、最近同步时刻中的至少一种。
  21. 根据权利要求14至20中任一项所述的电子设备,其特征在于,
    所述第一范围的下限大于等于所述第一范围的上限;
    位于第一范围的文件副本的同步优先级小于所述位于第二范围的文件副本的同步优先级;
    同步优先级小的文件副本会被优先同步。
  22. 根据权利要求14至20中任一项所述的电子设备,其特征在于,
    所述第一范围的上限小于所述第一范围的下限;
    位于第一范围的文件副本的同步优先级大于所述位于第二范围的文件副本的同步优先级;
    同步优先级小的文件副本会被优先同步。
  23. 根据权利要求14至22中任一项所述的电子设备,其特征在于,
    所述多个文件副本包括第一文件副本、第二文件副本;
    所述第一文件副本的老化程度位于所述第一范围,所述第一文件副本的老化程度位于所述第一范围;
    在所述第一文件副本的老化程度小于所述第二文件副本的老化程度情况下,所述第一文件副本的同步优先级大于所述第二文件副本的同步优先级;
    在所述第一文件副本的老化程度大于所述第二文件副本的老化程度情况下,所述第一文件副本的优先级小于所述第二文件副本的同步优先级;
    同步优先级小的文件副本会被优先同步。
  24. 根据权利要求23所述的电子设备,其特征在于,
    在所述第一文件副本的老化程度等于所述第二文件副本的老化程度情况下,并且在所述第一文件副本的同步数据的数据量小于所述第二文件副本的同步数据的数据量情况下,所述第一文件副本的同步优先级小于所述第二文件副本的同步优先级;
    在所述第一文件副本的老化程度等于所述第二文件副本的老化程度情况下,并且在所述第一文件副本的同步数据的数据量大于所述第二文件副本的同步数据的数据量情况下,所述第一文件副本的同步优先级大于所述第二文件副本的同步优先级。
  25. 根据权利要求23所述的电子设备,其特征在于,
    在所述第一文件副本的老化程度等于所述第二文件副本的老化程度情况下,所述第一文件副本的同步优先级等于所述第二文件副本的同步优先级。
  26. 根据权利要求14至22中任一项所述的电子设备,其特征在于,
    所述多个文件副本包括第三文件副本、第四文件副本;
    所述第三文件副本的老化程度位于所述第二范围,所述第四文件副本的老化程度位于所述第二范围;
    在所述第三文件副本的同步数据的数据量小于所述第四文件副本的同步数据的数据量情况下,所述第三文件副本的同步优先级小于所述第四文件副本的同步优先级;
    在所述第三文件副本的同步数据的数据量大于所述第四文件副本的同步数据的数据量情况下,所述第三文件副本的同步优先级大于所述第四文件副本的同步优先级;
    同步优先级小的文件副本会被优先同步。
  27. 一种芯片系统,所述芯片系统应用于电子设备,所述芯片系统包括一个或多个处理器,所述处理器用于调用计算机指令以使得所述电子设备执行如权利要求1至13中任一项所述的方法。
  28. 一种计算机可读存储介质,包括指令,其特征在于,当所述指令在电子设备上运行时,使得所述电子设备执行如权利要求1至13中任一项所述的方法。
PCT/CN2022/106900 2021-07-22 2022-07-20 多文件同步方法及电子设备 WO2023001208A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202110832126.5 2021-07-22
CN202110832126.5A CN115700493A (zh) 2021-07-22 2021-07-22 多文件同步方法及电子设备

Publications (1)

Publication Number Publication Date
WO2023001208A1 true WO2023001208A1 (zh) 2023-01-26

Family

ID=84979727

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/106900 WO2023001208A1 (zh) 2021-07-22 2022-07-20 多文件同步方法及电子设备

Country Status (2)

Country Link
CN (1) CN115700493A (zh)
WO (1) WO2023001208A1 (zh)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1677355A (zh) * 2004-03-31 2005-10-05 深圳市朗科科技有限公司 文件同步更新的方法、系统及装置
US20060224620A1 (en) * 2005-03-29 2006-10-05 Microsoft Corporation Automatic rules-based device synchronization
CN104008116A (zh) * 2013-02-27 2014-08-27 联想(北京)有限公司 一种文件同步方法及电子设备
CN104283932A (zh) * 2013-07-12 2015-01-14 鸿富锦精密工业(深圳)有限公司 文件同步系统及方法
CN111797065A (zh) * 2020-05-26 2020-10-20 武汉长杰信息科技有限公司 一种基于云存储技术的云同步方法及系统

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1677355A (zh) * 2004-03-31 2005-10-05 深圳市朗科科技有限公司 文件同步更新的方法、系统及装置
US20060224620A1 (en) * 2005-03-29 2006-10-05 Microsoft Corporation Automatic rules-based device synchronization
CN104008116A (zh) * 2013-02-27 2014-08-27 联想(北京)有限公司 一种文件同步方法及电子设备
CN104283932A (zh) * 2013-07-12 2015-01-14 鸿富锦精密工业(深圳)有限公司 文件同步系统及方法
CN111797065A (zh) * 2020-05-26 2020-10-20 武汉长杰信息科技有限公司 一种基于云存储技术的云同步方法及系统

Also Published As

Publication number Publication date
CN115700493A (zh) 2023-02-07

Similar Documents

Publication Publication Date Title
WO2020108356A1 (zh) 一种应用显示方法及电子设备
US11573829B2 (en) Task processing method and apparatus, terminal, and computer readable storage medium
CN114443277A (zh) 内存管理方法、装置、电子设备以及计算机可读存储介质
WO2020093988A1 (zh) 一种图像处理方法及电子设备
WO2021159746A1 (zh) 文件共享方法、系统及相关设备
WO2022199509A1 (zh) 应用执行绘制操作的方法及电子设备
US20230021994A1 (en) Cross-Device Content Projection Method and Electronic Device
WO2021043046A1 (zh) 一种资源管控方法及设备
WO2021115112A1 (zh) 安装包的下载方法、分发方法、终端设备、服务器及系统
WO2022017474A1 (zh) 任务处理方法及相关装置
WO2021093626A1 (zh) 一种内存的管理方法及电子设备
WO2022078105A1 (zh) 内存管理方法、电子设备以及计算机可读存储介质
WO2022127632A1 (zh) 一种资源管控方法及设备
WO2021104122A1 (zh) 呼叫需求响应方法、装置及电子设备
WO2022033355A1 (zh) 一种邮件处理方法及电子设备
WO2023001208A1 (zh) 多文件同步方法及电子设备
WO2021238376A1 (zh) 功能包的加载方法、装置、服务器和电子设备
WO2023179682A1 (zh) 一种设备协同方法
WO2024045841A1 (zh) 存储的方法、装置和电子设备
WO2024041456A1 (zh) 一种应用数据保存方法及电子设备
WO2022206763A1 (zh) 一种显示方法、电子设备和系统
WO2022166550A1 (zh) 数据传输方法及电子设备
WO2022068578A1 (zh) 文件共享方法和电子设备
WO2023071472A1 (zh) 应用下载安装方法、应用老化方法及电子设备
WO2022228102A1 (zh) 通信资源调度方法和电子设备

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 22845373

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE