shared-memory

Assigning strings in shared memory processes

≯℡__Kan透↙ 提交于 2020-01-03 15:16:11
问题 I have a program that needs to share a string between two processes. I have declared a struct that contains an array of *char . This struct is allocated with shmget and shmat before the main process is forked. typedef struct Queue { int index; char *directory[10]; } Queue; In one of the processes, I try to set the value: ( data->dir_name is a *char to a string such as "/data1") queue->directory[i] = data->dir_name; // Option 1 queue->directory[i] = "foo"; // Option 2 My question is, what is

Assigning strings in shared memory processes

爱⌒轻易说出口 提交于 2020-01-03 15:16:05
问题 I have a program that needs to share a string between two processes. I have declared a struct that contains an array of *char . This struct is allocated with shmget and shmat before the main process is forked. typedef struct Queue { int index; char *directory[10]; } Queue; In one of the processes, I try to set the value: ( data->dir_name is a *char to a string such as "/data1") queue->directory[i] = data->dir_name; // Option 1 queue->directory[i] = "foo"; // Option 2 My question is, what is

C++ STL map in shared memory

允我心安 提交于 2020-01-03 04:47:32
问题 i need to place a STL map in shared memory. Also have multiple process access that map. Any pointers to how it is done ? I have checked this link. But need a more simpler method. Map in Shared memory 回答1: For this to work you need to use a custom allocator that will allocate from the shared memory region, so that the map nodes are all in shared memory, and so that the pointer type of the allocator is not just a raw pointer but can refer to the shared memory region when it is mapped to

find the pages accessed by thread

泪湿孤枕 提交于 2020-01-03 01:47:09
问题 I am looking for some scheduling options based on data accessed by threads. Is there any way to find the pages of cache accessed by a specific thread. If i have two threads from two different processes, is it possible to find the common data/pages accessed by both the threads 回答1: Two threads from the same process are potentially sharing the whole process memory space. If the programme does not restrict access to certain regions of memory to the threads, it might be difficult to know exactly

write file in memory with java.nio?

て烟熏妆下的殇ゞ 提交于 2020-01-02 03:36:08
问题 With nio it is possible to map an existing file in memory. But is it possible to create it only in memory without file on the hard drive ? I want to mimic the CreateFileMapping windows functions which allow you to write in memory. Is there an equivalent system in Java ? The goal is to write in memory in order for another program ( c ) to read it. 回答1: Have a look at the following. A file is created but this might be as close as your going to get. MappedByteBuffer MappedByteBuffer.load()

Cannot append items to multiprocessing shared list

♀尐吖头ヾ 提交于 2020-01-02 03:27:27
问题 I'm using multiprocessing to create sub-process to my application. I also share a dictionary between the process and the sub-process. Example of my code: Main process: from multiprocessing import Process, Manager manager = Manager() shared_dict = manager.dict() p = Process(target=mysubprocess, args=(shared_dict,)) p.start() p.join() print shared_dict my sub-process: def mysubprocess(shared_dict): shared_dict['list_item'] = list() shared_dict['list_item'].append('test') print shared_dict In

ftok() collisions

霸气de小男生 提交于 2020-01-02 01:59:13
问题 I am using ftok() to generate identifiers for shared memory segments used by a C application. I am having problems, where on one box I am getting collisions with the identifiers used by root. I can fix it in this instance by hacking the code, but I would like a more robust solution. The application is installed into its own logical volume, and the path supplied to ftok is the binaries directory for the application (within that lv). The IDs supplied start at 1 and there are usually half a

ftok() collisions

天大地大妈咪最大 提交于 2020-01-02 01:59:06
问题 I am using ftok() to generate identifiers for shared memory segments used by a C application. I am having problems, where on one box I am getting collisions with the identifiers used by root. I can fix it in this instance by hacking the code, but I would like a more robust solution. The application is installed into its own logical volume, and the path supplied to ftok is the binaries directory for the application (within that lv). The IDs supplied start at 1 and there are usually half a

Python 2.6: Process local storage while using multiprocessing.Pool

纵饮孤独 提交于 2020-01-01 19:36:30
问题 I'm attempting to build a python script that has a pool of worker processes (using mutiprocessing.Pool) across a large set of data. I want each process to have a unique object that gets used across multiple executes of that process. Psudo code: def work(data): #connection should be unique per process connection.put(data) print 'work done with connection:', connection if __name__ == '__main__': pPool = Pool() # pool of 4 processes datas = [1..1000] for process in pPool: #this is the part i'm

Shared memory and IPC [closed]

只愿长相守 提交于 2020-01-01 09:45:47
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 6 months ago . I was reading a tutorial about shared memory and found the following statement: "If a process wishes to notify another process that new data has been inserted to the shared memory, it will have to use signals, message queues, pipes, sockets, or other types of IPC.". So what is