• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Communicating a memory entry between two unrelated processes
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Communicating a memory entry between two unrelated processes


  • Subject: Communicating a memory entry between two unrelated processes
  • From: "Timothy J. Wood" <email@hidden>
  • Date: Fri, 17 Jun 2005 21:14:46 -0700



I was testing setting up a shared memory entry between two tasks. The tasks process started out with the following code. The interesting bit here was that for expediency, I allocated the memory object and registered it with the bootstrap server. I was assuming that if all users tasks with rights to the memory entry died, that the bootstrap server wouldn't hold onto the port (just like it does for my mig server ports).

But, if I run this code twice, the second registration fails with BOOTSTRAP_SERVICE_ACTIVE. Clearly, I assumed wrong.

Is there any way to get the port transfered between two processes (both with the same uid in this case) without having a mig server in the vending process to return the memory entry port to callers?


-tim

----

    kern_return_t krc;
    vm_address_t  addr;
    vm_size_t byteCount = 0x20000;

    krc = vm_allocate(mach_task_self(), &addr, byteCount, TRUE);
    if (krc != KERN_SUCCESS) {
        mach_error("vm_allocate", krc);
    return 1;
    }

mem_entry_name_port_t memoryEntry = PORT_NULL;
krc = mach_make_memory_entry(mach_task_self(), &byteCount, addr, VM_PROT_READ|VM_PROT_WRITE, &memoryEntry, PORT_NULL/*parent*/);
if (krc != KERN_SUCCESS) {
mach_error("mach_make_memory_entry", krc);
return 1;
}


mach_port_t bootstrapPort;
krc = task_get_bootstrap_port(mach_task_self(), &bootstrapPort);
if (krc != KERN_SUCCESS) {
fprintf(stderr, "task_get_bootstrap_port, krc = %d, %s\n", krc, mach_error_string(krc));
return 1;
}


krc = bootstrap_register(bootstrap_port, "Memory Test", memoryEntry);
if (krc != KERN_SUCCESS) {
fprintf(stderr, "bootstrap_register, krc = %d, %s\n", krc, mach_error_string(krc));
return 1;
}


----

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Prev by Date: Shared memory locking
  • Next by Date: UID of parent process
  • Previous by thread: Shared memory locking
  • Next by thread: UID of parent process
  • Index(es):
    • Date
    • Thread