Method, device and equipment for creating named semaphore, medium and product
By using the data structure of semaphore objects and atomic variables in the famous semaphore creation method and mapping them to the process memory space, the compatibility problem caused by relying on file links in the existing technology is solved, and more efficient named semaphore creation and initialization is achieved.
Patent Information
- Application Number
- CN202411678342.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-22
- Publication Date
- 2025-03-25
- Estimated Expiration
- 2044-11-22
AI Technical Summary
The existing famous semaphore creation method relies on file links, has compatibility issues and is not compatible on operating systems that do not support file links.
By obtaining a famous semaphore file, setting its size to the preset data structure size, including semaphore objects and atomic variables, mapping the file to the process memory space, and calling the preset interface to check and initializing the data structure, realizing the creation and initialization of the famous semaphore.
It implements the creation and initialization of famous semaphores without relying on file links, with better compatibility and performance.
Smart Images

Figure CN119690688A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of communication technology, and in particular to a method, device, equipment, medium and product for creating a named semaphore. Background Art
[0002] In a multitasking operating system, a named semaphore is a synchronization mechanism commonly used in multi-process programming. Existing methods for creating named semaphores usually rely on file system operations, such as file creation, writing, and linking. A typical implementation method includes the following steps: obtaining a named semaphore file name based on the input semaphore name. Determine whether the system already has the named semaphore file. If so, directly open and map it to the process memory space. If not, execute the creation initialization process, initialize the semaphore value in the memory, then create a temporary file, and write the initialized semaphore value to the file. Use the link file operation to atomically link the temporary file to the final semaphore file. Map the file to the process memory, and access the mapped memory according to the semaphore data structure. In this way, the creation and initialization of the named semaphore are completed. Multiple processes use the same semaphore name to access the memory mapping of the same semaphore file in their respective processes, thereby achieving cross-process access to the same named semaphore.
[0003] However, the inventors have found that the prior art has at least the following problems: the existing method uses a file link operation to atomically link a temporary file that stores an initialized semaphore to a semaphore file, thereby ensuring the multi-process and multi-thread correctness of the creation process. This method relies on file links and has compatibility issues. On an operating system that does not support file links, this solution is incompatible. Summary of the invention
[0004] The purpose of the embodiments of the present invention is to provide a method, apparatus, device, medium and product for creating a named semaphore, which can realize the creation and initialization of the named semaphore without relying on file links and has better compatibility and performance.
[0005] To achieve the above object, an embodiment of the present invention provides a method for creating a named semaphore, comprising:
[0006] Get the named semaphore file;
[0007] Setting the size of the named semaphore file to the size of a preset data structure; the data structure includes a semaphore object and an atomic variable, and the atomic variable is used to synchronize the creation and initialization behaviors of multiple processes at the same time;
[0008] Mapping the named semaphore file to the memory space of the process, so that different processes can access and use the named semaphore according to the data structure through the mapped memory address;
[0009] Call the preset interface to check and initialize the data structure.
[0010] As an improvement of the above solution, the step of obtaining a named semaphore file includes:
[0011] Generate a named semaphore file name based on the semaphore name;
[0012] Check whether the named semaphore file corresponding to the named semaphore file name exists;
[0013] When the named semaphore file does not exist, create a named semaphore file;
[0014] When the named semaphore file exists, open the named semaphore file.
[0015] As an improvement of the above scheme, the semaphore object includes a counter, a scope attribute and a waiter count; wherein, the counter is used to indicate the number of available resources, the scope attribute is used to indicate whether the semaphore is exclusive to this process, and the waiter count is used to indicate the number of threads currently blocked waiting for the semaphore.
[0016] As an improvement of the above solution, the atomic variable includes the following states: uninitialized, initializing, and initialization completed.
[0017] As an improvement of the above solution, calling a preset interface to check and initialize the data structure includes:
[0018] Calling the atomic comparison modification interface to compare whether the atomic variable is in an uninitialized state;
[0019] When the atomic variable is in an uninitialized state, modifying the atomic variable to be in an initializing state;
[0020] Set the counter value of the semaphore object to the initial semaphore value input by the user;
[0021] Calling an atomic write operation modifies the atomic variable to an initialization completed state and returns a success status code.
[0022] The calling of a preset interface to check and initialize the data structure also includes:
[0023] When the atomic variable is not in an uninitialized state, or when modifying the atomic variable to be in an initializing state fails, calling an atomic read interface to determine whether the atomic variable is in an initializing state;
[0024] When the atomic variable is in the initialization state, determining whether the atomic variable changes to the initialization completion state within a preset cycle number threshold;
[0025] If yes, it returns a success status code; if no, it returns a failure status code.
[0026] As an improvement of the above solution, the method further includes:
[0027] The address of the semaphore object and the file information of the named semaphore file are bound and saved.
[0028] As an improvement of the above solution, the address of the semaphore object and the file information of the named semaphore file are bound and saved, including:
[0029] Obtaining the inode number of the named semaphore file in the file system;
[0030] The index node number and the address of the semaphore object are stored in pairs.
[0031] The embodiment of the present invention further provides a device for creating a named semaphore, including:
[0032] File acquisition module, used to obtain the named semaphore file;
[0033] A file size setting module, used to set the size of the named semaphore file to the size of a preset data structure; the data structure includes a semaphore object and an atomic variable, and the atomic variable is used to synchronize the creation and initialization behaviors of multiple processes at the same time;
[0034] A file mapping module, used for mapping the named semaphore file to the memory space of the process, so that different processes can access and use the named semaphore according to the data structure through the mapped memory address;
[0035] The initialization module is used to call a preset interface to check and initialize the data structure.
[0036] An embodiment of the present invention also provides a device for creating a named semaphore, comprising a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein when the processor executes the computer program, the method for creating a named semaphore as described in any one of the above is implemented.
[0037] An embodiment of the present invention further provides a computer-readable storage medium, which includes a stored computer program, wherein when the computer program is running, the device where the computer-readable storage medium is located is controlled to execute any of the methods for creating a named semaphore as described above.
[0038] An embodiment of the present invention further provides a computer program product, which includes a computer program or a computer instruction. When the computer program or the computer instruction is executed by a processor, the method for creating a named semaphore as described in any one of the above is implemented.
[0039] Compared with the prior art, the method, device, equipment, medium and product for creating a named semaphore disclosed in the present invention create a named semaphore file, set the size of the named semaphore file to the size of a preset data structure; the data structure includes a semaphore object and an atomic variable, and the atomic variable is used to synchronize the creation and initialization behaviors of multiple processes at the same time; the named semaphore file is mapped to the memory space of the process, so that different processes can access and use the named semaphore according to the data structure through the mapped memory address; and call a preset interface to check and initialize the data structure. The present invention defines a data structure containing a semaphore and an atomic variable, initializes it by directly operating the mapped memory, and realizes concurrent control and synchronization of the semaphore initialization process through atomic variables, realizes the creation and initialization of a named semaphore without relying on the file link-related operations of the file system, and has better compatibility and performance. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] Figure 1 It is a flowchart of a method for creating a named semaphore provided by an embodiment of the present invention;
[0041] Figure 2 is a schematic diagram of a process for creating and initializing a data structure according to an embodiment of the present invention;
[0042] Figure 3 It is a structural schematic diagram of a device for creating a named semaphore provided by an embodiment of the present invention;
[0043] Figure 4 The invention is a schematic diagram of the structure of a device for creating a named semaphore provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0044] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0045] In the description of the present application, it should be understood that the terms "center", "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside", "outside", etc., indicating orientations or positional relationships, are based on the orientations or positional relationships shown in the accompanying drawings, and are only for the convenience of describing the present application and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore should not be understood as a limitation on the present application.
[0046] The terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features. In the description of this application, unless otherwise specified, "plurality" means two or more.
[0047] In the description of this application, it should be noted that, unless otherwise clearly specified and limited, the terms "installed", "connected", and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or it can be indirectly connected through an intermediate medium, or it can be the internal communication of two components. For ordinary technicians in this field, the specific meanings of the above terms in this application can be understood according to specific circumstances.
[0048] See also Figure 1 , is a flow chart of a method for creating a named semaphore provided by an embodiment of the present invention. The embodiment of the present invention provides a method for creating a named semaphore, including steps S11 to S14:
[0049] S11, obtain the famous semaphore file;
[0050] S12, setting the size of the named semaphore file to the size of a preset data structure; the data structure includes a semaphore object and an atomic variable, and the atomic variable is used to synchronize the creation and initialization behaviors of multiple processes at the same time;
[0051] S13, mapping the named semaphore file to the memory space of the process, so that different processes can access and use the named semaphore according to the data structure through the mapped memory address;
[0052] S14, calling a preset interface to check and initialize the data structure.
[0053] In the embodiment of the present invention, a data structure is first designed, including a semaphore object sem member and an atomic variable lock member. The semaphore object is used to support the operation of the semaphore's own semantics, and the specific definition is related to the semaphore implementation. The atomic variable is used to synchronize the creation and initialization behaviors that may be performed simultaneously by multiple processes or threads. The specific data structure design is as follows:
[0054] struct sem_file__mgmt
[0055] {
[0056] sem_t sem;
[0057] atomict_t lock;
[0058] };
[0059] Then, in combination with the data structure, a named semaphore is created and initialized. First, a named semaphore file is created, and the size of the named semaphore file is set to sizeof(struct sem_file__mgmt), that is, the size of the named semaphore file is the size of the data structure struct sem_file_mgmt. A memory mapping interface such as mmap is called to map the named semaphore file to the memory space of the process, and the mapping size is the size of the data structure struct sem_file_mgmt. The obtained memory address can be accessed and used according to the data structure struct sem_file_mgmt, where the sem member address is the address of the semaphore. Finally, the pre-designed interface check_and_init_sem_mgmt is called to check and initialize the data structure to ensure that the semaphore object sem has been initialized at this moment, and the creation and initialization of the named semaphore are completed. Multiple processes access the memory mapping of the same semaphore file in their respective processes through the same semaphore name, thereby realizing cross-process access to the same named semaphore.
[0060] By adopting the technical means of the embodiment of the present invention, a data structure including a semaphore and an atomic variable is defined, which is initialized by directly operating the mapped memory, and concurrent control and synchronization of the semaphore initialization process are realized through atomic variables. Without relying on file link-related operations of the file system, the creation and initialization of a named semaphore is realized, which has better compatibility and performance.
[0061] As a preferred implementation, the embodiment of the present invention is further implemented on the basis of the above embodiment, step S11, that is, obtaining the named semaphore file, includes steps S111 to S114:
[0062] S111, generating a named semaphore file name according to the semaphore name;
[0063] S112, checking whether the named semaphore file corresponding to the named semaphore file name exists;
[0064] S113. When the named semaphore file does not exist, create a named semaphore file;
[0065] S114. When the named semaphore file exists, open the named semaphore file.
[0066] In an embodiment of the present invention, a named semaphore file name is obtained according to the semaphore name input by the user, and the path of the file name is recommended to be a memory file system path to facilitate automatic clearing of the semaphore file after the system is restarted or powered off.
[0067] Use the regular file operation interface open to check whether the named semaphore file corresponding to the generated named semaphore file name exists. If the file exists, open the named semaphore file; if the file does not exist, create the named semaphore file and set appropriate permissions. Further perform steps such as setting the size of the named semaphore file.
[0068] As a preferred implementation, the embodiment of the present invention is further implemented on the basis of the above embodiment, and the designed data structure is further limited, the semaphore object sem member includes a counter counter, a scope attribute private and a waiter count waiters;
[0069] Among them, the counter counter is used to indicate the number of available resources, the scope attribute private is used to indicate whether the semaphore is exclusive to this process, and the waiters count waiters is used to indicate the number of threads currently blocked waiting for the semaphore.
[0070] The atomic variable lock member includes the following states: uninitialized, initializing, and initialization completed, which are represented by 0, 1, and 2 respectively, that is, 0 represents uninitialized, 1 represents initializing, and 2 represents initialization completed.
[0071] In the process of creating and initializing a named semaphore, the size of the named semaphore file is set to sizeof(struct sem_file__mgmt) by calling the file general operation interface ftruncate, that is, the size of the data structure struct sem_file_mgmt. If the file has no content before, the newly extended content will be automatically filled with zeros. If there is already content, the content remains unchanged. This ensures that the initial value of lock is 0, the sem counter counter is 0, the waiter count waiters is 0, and the scope attribute private is 0, that is, cross-process sharing.
[0072] As a preferred implementation, the embodiment of the present invention is further implemented on the basis of the above embodiment, and the steps of checking and initializing the data structure are further limited. Then step S14, that is, calling the preset interface to check and initialize the data structure, includes steps S141 to S148:
[0073] S141, calling the atomic comparison modification interface to compare whether the atomic variable is in an uninitialized state;
[0074] S142, when the atomic variable is in an uninitialized state, modifying the atomic variable to an initializing state;
[0075] S143, setting the counter value of the semaphore object to the semaphore initial value input by the user;
[0076] S144. Calling an atomic write operation to modify the atomic variable to an initialization completed state, and returning a success status code.
[0077] S145, when the atomic variable is not in an uninitialized state, or when modifying the atomic variable to be in an initializing state fails, calling an atomic read interface to determine whether the atomic variable is in an initializing state;
[0078] S146, when the atomic variable is in the initialization state, determining whether the atomic variable has changed to the initialization completion state within a preset cycle number threshold;
[0079] S147, if yes, return a success status code;
[0080] S148. If not, return a failure status code.
[0081] See also Figure 2 , is a schematic diagram of a process of creating and initializing a data structure according to an embodiment of the present invention. In an embodiment of the present invention, the process of using the designed check_and_init_sem_mgmt interface to check and initialize the data structure can be summarized as follows:
[0082] Call the atomic comparison modification interface atomic_cmpxchg to compare whether the lock value is 0. If it is 0, modify it to 1. If the lock value is not 0, the modification fails. If atomic_cmpxchg successfully modifies the lock value, it means that the semaphore has not been initialized and is currently exclusively occupied by the program. Therefore, continue to set the counter value of the sem member to the semaphore initial value value passed in by the user, and then call the atomic write operation atomic_write to modify the lock value to 2, indicating that the semaphore initialization is complete and returns success. If atomic_cmpxchg fails to modify the lock value, continue to execute the following steps.
[0083] Call the atomic read interface atomic_read to read the lock value and determine whether it is 1. If so, execute a limited number of loops, such as 1000 times, to call atomic_read to read the lock value and determine whether it is equal to 2. If so, end the loop and return success. If the lock value is still not 2 after the loop ends, return failure. If not, execute the following steps.
[0084] Call the atomic read interface atomic_read to read the lock value and determine whether it is 2. If it is, it means that the semaphore has been initialized before, and the function returns success. If the lock value is not 2, the function returns failure.
[0085] At this point, the program can ensure that the semaphore object sem has been initialized.
[0086] By adopting the technical means of the embodiment of the present invention, a data structure including a semaphore and an atomic variable is defined, and the atomic variable has three states, which respectively represent uninitialized, initializing, and initialization completed. Initialization is performed by directly operating the mapped memory, and concurrent control and synchronization of the semaphore initialization process are realized through atomic variables. The creation and initialization of a named semaphore are realized without relying on file link related operations of the file system, and the compatibility and performance are better.
[0087] As a preferred implementation, the embodiment of the present invention is further implemented on the basis of the above embodiment, and the method further includes step S15:
[0088] S15. Bind and save the address of the semaphore object and the file information of the named semaphore file.
[0089] In the embodiment of the present invention, after the semaphore object sem has been initialized, in order to ensure that the same process returns the same semaphore address when opening the same named semaphore multiple times, the sem address and the named semaphore file information need to be saved in pairs.
[0090] Preferably, the step of binding and saving the address of the semaphore object and the file information of the named semaphore file comprises steps S151 to S152:
[0091] S151, obtaining the inode number of the named semaphore file in the file system;
[0092] S152. Save the index node number and the address of the semaphore object in pairs.
[0093] In an embodiment of the present invention, by obtaining the index node number st_ino of the named semaphore file in the file system, the index node number st_ino and the sem address are saved in pairs. Each time the named semaphore is opened, the obtained st_ino is traversed and compared with the st_ino already recorded in the process. If st_ino already exists, the newly created sem address can be released and the sem address corresponding to the st_ino in the record is directly returned.
[0094] By adopting the technical means of the embodiment of the present invention, the address of the semaphore object and the file information of the named semaphore file are stored in pairs, so that the same process can return the same semaphore address when opening the same named semaphore multiple times.
[0095] See also Figure 3 , is a schematic diagram of a structure of a device for creating a named semaphore provided by an embodiment of the present invention. The embodiment of the present invention further provides a device 20 for creating a named semaphore, including:
[0096] The file acquisition module 21 is used to acquire a named semaphore file;
[0097] A file size setting module 22, used to set the size of the named semaphore file to the size of a preset data structure; the data structure includes a semaphore object and an atomic variable, and the atomic variable is used to synchronize the creation and initialization behaviors of multiple processes at the same time;
[0098] A file mapping module 23, used for mapping the named semaphore file to the memory space of the process, so that different processes can access and use the named semaphore according to the data structure through the mapped memory address;
[0099] The initialization module 24 is used to call a preset interface to check and initialize the data structure.
[0100] As a preferred implementation, the file acquisition module 21 is specifically used for:
[0101] Generate a named semaphore file name based on the semaphore name;
[0102] Check whether the named semaphore file corresponding to the named semaphore file name exists;
[0103] When the named semaphore file does not exist, create a named semaphore file;
[0104] When the named semaphore file exists, open the named semaphore file.
[0105] As a preferred implementation, the semaphore object includes a counter, a scope attribute and a waiter count; wherein the counter is used to indicate the number of available resources, the scope attribute is used to indicate whether the semaphore is exclusive to this process, and the waiter count is used to indicate the number of threads currently blocked waiting for the semaphore.
[0106] The atomic variable includes the following states: uninitialized, initializing, and initialization completed.
[0107] As a preferred implementation, the initialization module 24 is specifically used for:
[0108] Calling the atomic comparison modification interface to compare whether the atomic variable is in an uninitialized state;
[0109] When the atomic variable is in an uninitialized state, modifying the atomic variable to be in an initializing state;
[0110] Set the counter value of the semaphore object to the initial semaphore value input by the user;
[0111] Calling an atomic write operation modifies the atomic variable to an initialization completed state and returns a success status code.
[0112] When the atomic variable is not in an uninitialized state, or when modifying the atomic variable to be in an initializing state fails, calling an atomic read interface to determine whether the atomic variable is in an initializing state;
[0113] When the atomic variable is in the initialization state, determining whether the atomic variable changes to the initialization completion state within a preset cycle number threshold;
[0114] If yes, it returns a success status code; if no, it returns a failure status code.
[0115] As a preferred embodiment, the device 20 further includes:
[0116] The file saving module is used to bind and save the address of the semaphore object and the file information of the named semaphore file.
[0117] Preferably, the file saving module is specifically used for:
[0118] Obtaining the inode number of the named semaphore file in the file system;
[0119] The index node number and the address of the semaphore object are stored in pairs.
[0120] It should be noted that a device for creating a named semaphore provided in an embodiment of the present invention is used to execute all process steps of a method for creating a named semaphore in the above embodiment, and the working principles and beneficial effects of the two correspond one to one, so they will not be described in detail.
[0121] By adopting the technical means of the embodiment of the present invention, a data structure including a semaphore and an atomic variable is defined, and the atomic variable has three states, which respectively represent uninitialized, initializing, and initialization completed. Initialization is performed by directly operating the mapped memory, and concurrent control and synchronization of the semaphore initialization process are realized through atomic variables. The creation and initialization of a named semaphore are realized without relying on file link related operations of the file system, and the compatibility and performance are better.
[0122] See also Figure 4 , is a structural diagram of a named semaphore creation device provided in an embodiment of the present invention. The embodiment of the present invention also provides a named semaphore creation device 30, including a processor 31, a memory 32, and a computer program stored in the memory and configured to be executed by the processor. When the processor executes the computer program, it implements the named semaphore creation method described in any one of the above embodiments.
[0123] An embodiment of the present invention also provides a computer-readable storage medium, which includes a stored computer program, wherein when the computer program is running, the device where the computer-readable storage medium is located is controlled to execute the method for creating a named semaphore as described in any one of the above embodiments.
[0124] An embodiment of the present invention further provides a computer program product, which includes a computer program or computer instructions. When the computer program or the computer instructions are executed by a processor, the method for creating a named semaphore as described in any one of the above embodiments is implemented.
[0125] A person skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program, and the program can be stored in a computer-readable storage medium, and when the program is executed, it can include the processes of the embodiments of the above-mentioned methods. The storage medium can be a disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM), etc.
[0126] The above is a preferred embodiment of the present invention. It should be pointed out that a person skilled in the art can make several improvements and modifications without departing from the principle of the present invention. These improvements and modifications are also considered to be within the scope of protection of the present invention.
Claims
1. A method for creating a named semaphore, characterized in that: include: Get the named semaphore file; Setting the size of the named semaphore file to the size of a preset data structure; The data structure includes a semaphore object and an atomic variable, wherein the atomic variable is used to synchronize the creation and initialization behaviors of multiple processes simultaneously; Mapping the named semaphore file to the memory space of the process, so that different processes can access and use the named semaphore according to the data structure through the mapped memory address; Call the preset interface to check and initialize the data structure.
2. The method for creating a named semaphore according to claim 1, wherein: The step of obtaining a named semaphore file includes: Generate a named semaphore file name based on the semaphore name; Check whether the named semaphore file corresponding to the named semaphore file name exists; When the named semaphore file does not exist, create a named semaphore file; When the named semaphore file exists, open the named semaphore file.
3. The method for creating a named semaphore according to claim 1, wherein: The atomic variable includes the following states: uninitialized, initializing, and initialization completed.
4. The method for creating a named semaphore according to claim 3, characterized in that: The calling of a preset interface to check and initialize the data structure includes: Calling the atomic comparison modification interface to compare whether the atomic variable is in an uninitialized state; When the atomic variable is in an uninitialized state, modifying the atomic variable to be in an initializing state; Set the counter value of the semaphore object to the initial semaphore value input by the user; Calling an atomic write operation modifies the atomic variable to an initialization completed state and returns a success status code.
5. The method for creating a named semaphore according to claim 4, characterized in that: The calling of a preset interface to check and initialize the data structure also includes: When the atomic variable is not in an uninitialized state, or when modifying the atomic variable to be in an initializing state fails, calling an atomic read interface to determine whether the atomic variable is in an initializing state; When the atomic variable is in the initialization state, determining whether the atomic variable changes to the initialization completion state within a preset cycle number threshold; If yes, it returns a success status code; if no, it returns a failure status code.
6. The method for creating a named semaphore according to any one of claims 1 to 5, characterized in that: The method further comprises: The address of the semaphore object and the file information of the named semaphore file are bound and saved.
7. A device for creating a named semaphore, characterized in that: include: File acquisition module, used to obtain the named semaphore file; A file size setting module, used to set the size of the named semaphore file to the size of a preset data structure; the data structure includes a semaphore object and an atomic variable, and the atomic variable is used to synchronize the creation and initialization behaviors of multiple processes at the same time; A file mapping module, used for mapping the named semaphore file to the memory space of the process, so that different processes can access and use the named semaphore according to the data structure through the mapped memory address; The initialization module is used to call a preset interface to check and initialize the data structure.
8. A device for creating a named semaphore, characterized in that: The method comprises a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein the processor implements the method for creating a named semaphore according to any one of claims 1 to 6 when executing the computer program.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored computer program, wherein when the computer program is executed, the device where the computer-readable storage medium is located is controlled to execute the method for creating a named semaphore according to any one of claims 1 to 6.
10. A computer program product, characterized in that The computer program product comprises a computer program or a computer instruction, and when the computer program or the computer instruction is executed by a processor, the method for creating a named semaphore according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Resource allocation method and resource allocation device for invoking function
CN103927191A
Inter-process thread mutex method
CN105511969A
System and method for dynamic transparent consistent application-replication of multi-process multi-threaded applications
US9135127B1