?? readme
字號:
This directory contains a portable module, i.e. non RTAI specific, that allows sharing memory among different real time tasks and Linux processes, simoultaneously. In fact it can be an alternative to SYSTEM V shared memory.It is self contained so you can freely arrange the all stuff in the way youlike taking what is needed from here.The services are symmetricall, i.e. the same calls can be used both in realtime tasks, i.e. within the kernel, and Linux processes:They are:#include "rtai_shm.h"unsigned long name;void *adr;int size;call to allocate memory:adr = rtai_malloc(name, size); //in user spaceadr = rtai_kmalloc(name, size); //in kernel (module) spacecall to free memory:rtai_free(name, adr); //in user spacertai_kfree(name); //in kernel (module) spaceThe first allocation does a real allocation, any subsequent call to allocatewith the same name from Linux processes just maps the area to the user space or return the related pointer to the already allocated space in kernel space.Analogously the freeing calls have just the effect of unmapping till the lastis done, as that is the one the really frees allocated memory. Clearly cooperating users have to use the same "name".The all stuff is based on an implementation of basic services made available by Tomasz (Tomek) Motylewski (motyl@stan.chemie.unibas.ch), i.e kvmem.h as obtained from motylewski.h.orig in this distribution.Such an implementation makes it easier for users to code the related services, as calls similar to Unix OS services can be used.Many thanks again to Tomek for his help and patience in answering my questions. This shared memory implementation has been very fast, in my standard, thank to his code and help. A couple of technicalities.- I followed Tomek's idea to use the char misc_device, Linux seems to install by default on major = 10, with minor = 254. You can change it to your preferred value by changing the macro RTAI_SHM_MISC_MINOR in rtai_shm.c. It is registered at insmod so you should be warned if the value is inappropriatefor your environment. - I used a fixed array list of allocated areas, instead of a list of pointers,as the related operations are not critical. You can make it to suite the size of your needs by changing the macro MAX_SLOTS in rtai_shm.c. As explained above the allocated area is identified by an unsigned long. To usealphanumeric mnemonic terms a couple of very simple functions are available totranslate a FOUR CHARACTERs string into and unsigned long, both in kernel and user space. They are:unsigned long nam2num(char *name);void num2nam(unsigned long num, char *name);So if you like to use them you can do:adr = rtai_malloc(nam2num("NAM1"), size);orrtai_free(num2nam("NAM1"), adr);
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -