Welcome, Guest. Please login or register.

Author Topic: Code compatibility to memory protection model on various platforms etc.  (Read 2536 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline MskoDestny

  • Sr. Member
  • ****
  • Join Date: Oct 2004
  • Posts: 363
    • Show all replies
    • http://www.retrodev.com
Quote

Jose wrote:
1- Generally, in most platforms, the library code is executed in the caller's memory space right ?

Every system I'm familiar with.

Quote
But in this case, the thing gets complicated because the library call sends a message to the process the calls the fucntion, so it might not work.

Why can't the receiver of the message just be another thread within the same process?

Quote
2- Do other platforms allow this easily ? I've done something a bit similar in the past with ports and signals and it was straightforward but I've done it on the Amiga (no memory protection). This one I want to be multiplatform, wich I think will probably be a big PITA...

AFAIK, all the major platforms that support memory protection also have some kind of mechanism for creating a region of memory that is shared between multiple processes. However, I believe the mechanism varies somewhat from platform to platform.
 

Offline MskoDestny

  • Sr. Member
  • ****
  • Join Date: Oct 2004
  • Posts: 363
    • Show all replies
    • http://www.retrodev.com
Re: Code compatibility to memory protection model on various platforms etc.
« Reply #1 on: August 03, 2007, 08:57:27 PM »
Quote

Jose wrote:
@MskoDestny
"Why can't the receiver of the message just be another thread within the same process?"

Because I'd like library usage to be as simple as calling any other function, without the need to create a message port, receive it's messages, processing them, and clean up everything in the end.

I'm not sure I follow. In both cases there is need for setup and cleanup. With a separate process you need to spawn the separate process and allocate a shared memory area. The user of the library will need to stick his buffers in the shared memory area if you want to avoid copying it. When you're done with the library the extra process needs to be closed and the shared memory freed.

With a separate thread, you need to spawn the thread and setup the mechanism by which you're going to send messages to it. There are no special memory allocation requirements put on the user of the library. When you're done you kill the thread and clean up your message mechanism.

Also, I don't see why you need a full OS message port. Just write a really simple message queue using some simple data structure (linked list perhaps) and a mutex to control access.

Of course, I should say I know next to nothing about programming on Amiga OS so perhaps I'm missing something here.