2012年3月24日星期六

Beats HeadphonesEstablishment of IPC communication system (such as the message queue

Establishment of IPC communication system (such as the message queue,Beats Headphones, shared memory) must specify a ID value.Typically, the value of ID through ftok function.Ftok prototypes as follows: key_t ftok (char * fname, int ID) parameters: fname you specified document ID is the son of the serial number.
Return value: in general the UNIX implementation, is the document indexing section points out, add sub serial number to get a return value of key_t.Such as specifying the index node number is 65538, converted to hexadecimal 16 0x010002,Moncler Store, and the ID you specify a value of 38, converted into 16 hexadecimal 0x26, the final key_t value returned is 0x26010002.
Query document index node number method is: LS - I when deleting document after reconstruction, index node number by the operating system according to the time of the document system usage allocation, so different and original, so the index node number is also different.
If you want to do and key_t values, to head to ensure that the ftok document to be removed, either do not use ftok, specify a fixed key_t value.In addition to say: in AIX operating system, there are multiple file systems, will be distributed in different file system on a two document with the same index node number, this time with the ftok on the two document operation, as long as the ID parameters are constant, the key_t values obtained by the same, create a message queue failure.
But this is quite rare.Because in the development relates to a variety of system platform, the system transplantion found ftok () function in different platforms exist some differences.Of course, prime cause does not depend on ftok () itself, and should be the operating system for file system management differences.
Test code is as follows: [Code] # include < stdio.h> include; # < sys / ipc.h>; main () {sprintf (" key =%0x / n", ftok; (" aaa.txt", 1000));} [/ code] tests involving the operating system: RedHat AS3U3, Sco OpenServer 5.
0.6,UGG Boots Sale, UnixWare 7.1.1, Solaris 9 x86 u7.In the RH AS3 environment, the modification of aaa.txt after the program output value has changed, stating that the document in the modified storage location changes.
In the Sco OpenServer 5.0.6,Moncler Coats, UnixWare 7.1.1, Solaris 9 x86 U7 executing the same program,Womens Nike Running Shoes, both for the aaa.txt file content to do what modifications to the output of the program without effect.Therefore, if in Linux through ftok (IPC), and ftok (key) related to configuration files, in the configuration file must be changed after the application of heavy.
Related articles:

没有评论:

发表评论