shared-memory

PHP - Access shared Memory created with C++

≯℡__Kan透↙ 提交于 2019-12-10 17:26:44
问题 Since a few days i'm trying to get the following thing to work: I have a tiny C++ program which reads some data continuously from a serial port. This data is stored in shared memory like this: HANDLE hMapFile; hMapFile = CreateFileMapping( INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, 10, NULL); LPCTSTR pBuf; pBuf = (LPTSTR) MapViewOfFileEx( hMapFile, FILE_MAP_ALL_ACCESS, 0, 0, 10, NULL); while(true) { //... some code ... CopyMemory((PVOID)pBuf, szMsg, (_tcslen(szMsg) * sizeof(TCHAR))); //..

When should I use Scope Locking (Application, Server, etc…) vs named locking in ColdFusion?

主宰稳场 提交于 2019-12-10 12:37:22
问题 When is it appropriate to use <cflock scope="application"> or it's ilk as opposed to <cflock name="foo">? Specifically, I'm interested in using CFLock to protect shared objects in the application, session, or server scopes, but I'm also interested in finding out about different uses of locking in ColdFusion. 回答1: You should use when reading and writing from things that can change in the application scope. For example: <cfquery name="application.myData"> select * from myTable </cfquery> You

mremap function failed to allocate new memory

╄→尐↘猪︶ㄣ 提交于 2019-12-10 12:13:54
问题 I have write the following code , but the code is still fiven me EEERROR message , which tells that the mremap failed to extend the memory. int main() { int size_of_mem = 1024 int fd = shm_open("/myregion", O_CREAT | O_RDWR, S_IRWXO | S_IRUSR | S_IWUSR); if (fd == -1) printf("ERROR in shm_open \n") ; if (ftruncate(fd, size_of_mem) == -1) printf("ERROR in ftruncate \n") ; int shm_address = mmap(0 , size_of_mem , PROT_READ | PROT_WRITE | PROT_EXEC ,MAP_SHARED , fd , 0) ; if (shm_address == MAP

How to get the next page/part/view of file, if i read part of file using MapViewOfFile?

别等时光非礼了梦想. 提交于 2019-12-10 11:55:28
问题 I am trying to use combination of functions CreateFileMapping , MapViewOfFile, FlushViewOfFile. the total buffer size is more than the mapped view. example buffer is 50KB. and mapped view is 2KB. in such scenario, i want to write the total buffer to a physical file, using the above function. First part i am able to write to file. but the remaining part how to write to file. I mean, how to move to next page and write the next part of data. #define MEM_UNIT_SIZE 100 -first module...Memory map

UNIX Shared memory and Semaphores in C

二次信任 提交于 2019-12-10 11:49:35
问题 I started a week ago understanding and working with semaphores and shared memory, and actually created this program; the problem is I can't find anything wrong with it. I've been looking at it for hours and everything seems correct. The code compiles and i can create the build but when I execute it nothing happens. #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/ipc.h> #include <sys/shm.h> #include <stdio.h> #include <sys/fcntl.h> #include <semaphore.h> #define

c++ Synchronize shared memory when reading

蓝咒 提交于 2019-12-10 11:23:59
问题 I want to synchronize a shared_memory_object for reading iff the shared_memory_object already exists. This is the code I am using for synchronization with a bool variable. boost::interprocess::shared_memory_object my_shared_mat; bool mat_ready = true; while (mat_ready) { try { my_shared_mat = boost::interprocess::shared_memory_object( boost::interprocess::open_only, // only open "shared_mat", // name boost::interprocess::read_only); // read-only mode mat_ready = false; } catch (boost:

Sharing executable memory pages in Linux?

旧街凉风 提交于 2019-12-10 11:14:50
问题 Is it possible to share executable pages on Linux for the sake of preserving space? I know that there are shared memory APIs that can be used to share memory between different processes but I don't think that is meant to be used for that. Basically, I want to have a shared memory region where some commonly used shared libraries can be loaded into. I want to get the dynamic linker to link against the preloaded (read only) images instead of having to load all of the shared library images into

difference between slurm sbatch -n and -c

纵然是瞬间 提交于 2019-12-10 11:06:51
问题 The cluster that I work with recently switched from SGE to SLURM. I was wondering what the difference between sbatch options --ntasks and --cpus-per-task ? --ntasks seemed appropriate for some MPI jobs that I ran but did not seem appropriate for some OpenMP jobs that I ran. For the OpenMP jobs in my SLURM script, I specified: #SBATCH --ntasks=20 All the nodes in the partition are 20core machines, so only 1 job should run per machine. However, multiple jobs were running simultaneously on each

how to attach to an existing shared memory segment

依然范特西╮ 提交于 2019-12-10 10:07:28
问题 I am having trouble with shared memory. I have one process that creates and writes to a shared memory segment just fine. But I cannot get a second process to attach that same existing segment. My second process can create a new shared segment if I use IPC_CREATE flag but I need to attach to the existing shared segment that was created by the 1st process. This is my code in the 2nd process: int nSharedMemoryID = 10; key_t tKey = ftok("/dev/null", nSharedMemoryID); if (tKey == -1) { std::cerr <

Boost interprocess unordered_map compilation

早过忘川 提交于 2019-12-10 10:07:23
问题 I'm using boost 1.53 and GCC 4.1.2 . I've tried to use boost unordered_map in some tests (documentation says, that it should work with shared memory), but i'm unable to compile my code. With interprocess::map instead of unordered everything is ok. Typedefs: typedef boost::interprocess::allocator<char, SegmentManager> CharAllocator; typedef boost::interprocess::basic_string<char, std::char_traits<char>, CharAllocator> ShmString; typedef ShmString HashKeyType; //ComplexType is a wrapper for