Method, server, and system for sharing resource data
AssigneeTencent Technology (Shenzhen) Company Limited
InventorsXichang Mo, Zheng Zhang
Life of this patent
Estimating the term…
Abstract
A method, a server, and a system for sharing resource data are provided. The method includes: preconfiguring a resource configuration file, reading a preset key value and an index name in the resource configuration file; requesting a memory space from an operating system according to the preset key value to create a shared memory; and loading resource data corresponding to the index name from a magnetic disk to the shared memory, and sharing the resource data with a process of each scene server on a same physical machine.
Claims15
A method for sharing resource data, applicable to a resource loading server that comprises one or more program instructions, a memory and one or more processors, the one or more program instructions being stored in the memory and executed by the one or more processors, the method comprising:
- reading a preset key value and an index name of resource data from a resource configuration file, wherein the resource configuration file is a resource configuration file preconfigured, the resource data is same logical data needed for processes of scene servers on a same physical machine as the resource loading server, and each scene server runs a corresponding process;
- requesting a memory space from an operating system of the resource loading server according to the preset key value to create a shared memory;
- loading the resource data corresponding to the index name from a magnetic disk to the shared memory;
- setting a signal amount and creating a signal amount key value corresponding to the signal amount, an initial value of the signal amount being a total number of the processes corresponding to the scene servers executed on the physical machine;
- storing the signal amount in the memory space of the operating system according to the signal amount key value;
- for each scene server:
- executing a wait operation on the signal amount and subtracting 1 from the signal amount in response to the scene server accessing a non-zero signal value in the signal amount according to the signal amount key value;
- and
- sending a process start command to the scene server after the wait operation is completed for starting the process corresponding to the scene server;
- and
- sharing the resource data with the processes of the scene servers on the same physical machine, wherein the signal amount becomes 0 after all of the processes of the scene servers have been started.
A method for sharing resource data, applicable to each scene server of a plurality of scene servers on a same physical machine, the method comprising:
- reading a signal amount key value from a resource loading server on the same physical machine;
- periodically accessing a signal amount from a memory space on the same physical machine according to the signal amount key value at a preset time interval;
- if the signal amount has a non-zero value, receiving a start process command from the resource loading server and starting a corresponding process of the scene server, the start process command being sent from the resource loading server after the resource loading server executing a wait operation on the signal amount by subtracting 1 from the signal amount;
- reading a preset key value in a resource configuration file preconfigured by the resource loading server, the resource configuration file comprising the preset key value and an index name of resource data, and the resource data being same logical data needed for the plurality of scene servers on the same physical machine;
- accessing a shared memory according to the preset key value, the shared memory being created by the resource loading server according to the preset key value, the shared memory storing the resource data loaded, according to the index name, by the resource loading server from a magnetic disk;
- and
- mapping the resource data in the shared memory to a memory space on the scene server.
A computer system, comprising:
- a resource loading server and a plurality of scene servers, wherein:
- the resource loading server and the plurality of scene servers reside on the same physical machine;
- the resource loading server is configured to:
- read a preset key value and an index name of resource data from a resource configuration file, wherein the resource data is same logical data needed for processes of the scene servers, and each scene server runs a corresponding process;
- request a memory space of an operating system according to the preset key value to create a shared memory;
- load the resource data corresponding to the index name from a magnetic disk to the shared memory;
- set a signal amount;
- create a signal amount key value corresponding to the signal amount, an initial value of the signal amount being a total number of the processes corresponding to the scene servers;
- and
- store the signal amount in the memory space of the operating system according to the signal amount key value;
- and
- each scene server is configured to periodically access the signal amount according to the signal amount key value at a preset time interval;
- the resource loading server is further configured to execute a wait operation on the signal amount to subtract 1 from the signal amount in response to one scene server accessing a non-zero signal value in the signal amount;
- and send a process start command to the one scene server after the wait operation is completed;
- and
- each scene server is further configured to start the corresponding process after receiving the process start command from the resource loading server, wherein the resource data is shared with the corresponding processes of the plurality of scene servers, and the signal amount becomes 0 after all of the processes of the scene servers have been started.
Dependencies are inferred from the claim text.