shared-memory

Shared memory: what's the difference between the key and the id?

邮差的信 提交于 2019-12-01 06:52:07
问题 When invoking ipcs -a , what is the difference between the key column and the id column? Here is an example output for ipcs command: ipcs -a ------ Shared Memory Segments -------- key shmid owner perms bytes nattch status 0x00000000 0 ybaumes 600 393216 2 dest 0x00000000 65537 ybaumes 700 8124648 2 dest 0x00000000 3932163 ybaumes 700 169376 2 dest 0x00000000 3604485 ybaumes 600 393216 2 dest 回答1: Firstly, the 'id' column in shared memory refers to the specific handler to the shared memory

How to use shared memory in android native code?

只愿长相守 提交于 2019-12-01 05:47:31
问题 I am porting an existing linux application to android. The application is using shared memory API's like shm_open() etc. Checking bionic in android source, I see that these API's are not supported. Hence I get a linking error during build. external/l2/avbtp.c:138: error: undefined reference to 'shm_open' external/l2/avbtp.c:151: error: undefined reference to 'shm_unlink' external/l2/avbtp.c:186: error: undefined reference to 'shm_unlink' How to resolve this correctly? 回答1: Android

Java concurrency - why doesn't synchronizing a setter (but not a getter) make a class thread-safe? [duplicate]

非 Y 不嫁゛ 提交于 2019-12-01 04:11:06
Possible Duplicate: Thread safety in Java class I'm reading Java concurrency in Practice , and I've come to an example that puzzles me. The authors state that this class is not threadsafe public class MutableInteger { private int number; public int getInt() { return number; } public void setInt(int val) { number = val; } } And they also state that synchronizing only one method (the setter for example) would not do; you have to syncronize both. My question is: Why? Wouldn't synchronizing the setter just do? Java has a happens before/happens after memory model. There needs to be some common

Connecting to SQL Server from java with TCP disabled

ぃ、小莉子 提交于 2019-12-01 03:52:29
I'm trying to connect to a local database (SQL Server 2008) from Java. I have disabled the tcp connections per customer requirements and I can't connect. I have to disable too the service SQL Server Browser. I write the next statement in Java: conexion = DriverManager.getConnection("jdbc:sqlserver://localhost\\SQLEXPRESS;user=user;password=password"); and I have the following error: "java.net.SocketTimeoutException: Receive timed out". (then it tells me that probably there is a firewall and that I should run the SQL Server Browser). If I try to connect from the Microsoft SQL Server Managment

Process VS thread : can two processes share the same shared memory ? can two threads ?

本秂侑毒 提交于 2019-12-01 03:34:13
After thinking about the the whole concept of shared memory , a question came up: can two processes share the same shared memory segment ? can two threads share the same shared memory ? After thinking about it a little more clearly , I'm almost positive that two processes can share the same shared memory segment , where the first is the father and the second is the son , that was created with a fork() , but what about two threads ? Thanks can two processes share the same shared memory segment? Yes and no. Typically with modern operating systems, when another process is forked from the first,

Garbage collector in Ruby 2.2 provokes unexpected CoW

狂风中的少年 提交于 2019-12-01 03:14:27
How do I prevent the GC from provoking copy-on-write, when I fork my process ? I have recently been analyzing the garbage collector's behavior in Ruby, due to some memory issues that I encountered in my program (I run out of memory on my 60core 0.5Tb machine even for fairly small tasks). For me this really limits the usefulness of ruby for running programs on multicore servers. I would like to present my experiments and results here. The issue arises when the garbage collector runs during forking. I have investigated three cases that illustrate the issue. Case 1: We allocate a lot of objects

Java concurrency - why doesn't synchronizing a setter (but not a getter) make a class thread-safe? [duplicate]

时光怂恿深爱的人放手 提交于 2019-12-01 02:32:38
问题 This question already has answers here : Closed 9 years ago . Possible Duplicate: Thread safety in Java class I'm reading Java concurrency in Practice , and I've come to an example that puzzles me. The authors state that this class is not threadsafe public class MutableInteger { private int number; public int getInt() { return number; } public void setInt(int val) { number = val; } } And they also state that synchronizing only one method (the setter for example) would not do; you have to

Shared memory access control mechanism for processes created by MPI

荒凉一梦 提交于 2019-12-01 01:12:05
I have a shared memory used by multiple processes, these processes are created using MPI . Now I need a mechanism to control the access of this shared memory. I know that named semaphore and flock mechanisms can be used to do this but just wanted to know if MPI provides any special locking mechanism for shared memory usage ? I am working on C under Linux. MPI actually does provide support for shared memory now (as of version 3.0). You might try looking at the One-sided communication chapter ( http://www.mpi-forum.org/docs/mpi-3.0/mpi30-report.pdf ) starting with MPI_WIN_ALLOCATE_SHARED (11.2.3

Condition Variable in Shared Memory - is this code POSIX-conformant?

自作多情 提交于 2019-11-30 21:41:08
Does the POSIX standard allow a named shared memory block to contain a mutex and condition variable? We've been trying to use a mutex and condition variable to synchronise access to named shared memory by two processes on a LynuxWorks LynxOS-SE system (POSIX-conformant). One shared memory block is called "/sync" and contains the mutex and condition variable, the other is "/data" and contains the actual data we are syncing access to. We're seeing failures from pthread_cond_signal() if both processes don't perform the mmap() calls in exactly the same order , or if one process mmaps in some other

How do I measure the size of a boost interprocess vector in shared memory?

被刻印的时光 ゝ 提交于 2019-11-30 21:05:09
I'm using boost::interprocess::vector to share some strings between processes, and I want to make sure I do not overflow the shared memory segment it lives in. How do I find how much space the vector takes in memory, and how much memory a special segment-allocated string will take? typedef boost::interprocess::managed_shared_memory::segment_manager SegmentManager; typedef boost::interprocess::allocator<char, SegmentManager> CharAllocator; typedef boost::interprocess::basic_string<char, std::char_traits<char>, CharAllocator> ShmString; typedef boost::interprocess::allocator<ShmString,