Welcome, Guest. Please login or register.

Author Topic: Stupid question about if it's possible to link and create two separate executables  (Read 7032 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline bloodline

  • Master Sock Abuser
  • Hero Member
  • *****
  • Join Date: Mar 2002
  • Posts: 12114
    • Show all replies
    • http://www.troubled-mind.com
Quote

Karlos wrote:
@Thorrin

That type of messaging would be extremely hit and miss under AmigaOS. You aren't supposed to use any absolute address (apart from when banging hardware regusters) and sharing variables in this way would be dangerous even if you could. There is no "ownership" possible - one thread may change the variable without the other being aware right in the middle of it doing something with it.

Fortunately amigaos does allow you to create message ports that can be registered (by name) with the system to allow interprocess communication by passing (by reference) messages between ports.

Still, neither of these seem particularly relevant to Jose's problem. There must be a way to create processes in pre v36 AmigaOS without having to load a segment list. How does CreateNewProc() do it?


Maybe he/you could look at the AROS code :-)

Offline bloodline

  • Master Sock Abuser
  • Hero Member
  • *****
  • Join Date: Mar 2002
  • Posts: 12114
    • Show all replies
    • http://www.troubled-mind.com
Just a quick question José...

Why don't you allocate some memory (making sure to set the MEMF_PUBLIC flag ;-)), then reserve the first word for use as a flag.
Then pass a pointer to this memory block to your child task.
Now both programs can use the memory block, but make sure you check the first word before you read/write the memory block.

If you want to read/write the memory block, read the first word, if it contains -1 (or something) then the memory block is in use, and you can't use it.

If it reads 0, then set the first word to -1 and use the memory block... once you finish using it write 0 to the first word.

That should do what you want to do.

Offline bloodline

  • Master Sock Abuser
  • Hero Member
  • *****
  • Join Date: Mar 2002
  • Posts: 12114
    • Show all replies
    • http://www.troubled-mind.com
Quote

Karlos wrote:
@bloodline

Slight variation on that - simply create a struct that has all your shared globals in it and pass a pointer to that structure (via a Message) to the other task.

That struct could also contain a SignalSemaphore as part of its definition which would be used solve the concurrency issue.


Hmmm... yeah that makes more sense... I got to stop thinking ASM :-)

Offline bloodline

  • Master Sock Abuser
  • Hero Member
  • *****
  • Join Date: Mar 2002
  • Posts: 12114
    • Show all replies
    • http://www.troubled-mind.com
Quote

Karlos wrote:
@bloodline

Slight variation on that - simply create a struct that has all your shared globals in it and pass a pointer to that structure (via a Message) to the other task.

That struct could also contain a SignalSemaphore as part of its definition which would be used solve the concurrency issue.


One point though, can you allocate the struct in memory that has an MEMF_PUBLIC flag? (I'm having visions of some pointer magic here :-P)

With my method, the memory is labled as sharable, so even if memory protection were implemented (no I'm not going to start a debate on that topic :-D), it would still work... but if you use a struct then the memory would be allocated from the Program's heap and would be protected against another task.


Offline bloodline

  • Master Sock Abuser
  • Hero Member
  • *****
  • Join Date: Mar 2002
  • Posts: 12114
    • Show all replies
    • http://www.troubled-mind.com
Quote

thorrin wrote:
Dern, y'all are going to make me get an AmigaOne and start coding up some stuff...  This all sounds like good fun.

-Thorrin


Why not just download AROS and Code up some stuff right now!?!?! :lol:

Offline bloodline

  • Master Sock Abuser
  • Hero Member
  • *****
  • Join Date: Mar 2002
  • Posts: 12114
    • Show all replies
    • http://www.troubled-mind.com
Quote

Jose wrote:
@bloodline

"One point though, can you allocate the struct in memory that has an MEMF_PUBLIC flag? (I'm having visions of some pointer magic here )....
 "... but if you use a struct then the memory would be allocated from the Program's heap and would be protected against another task."

Code: [Select]
struct OurStructure *OurMessage

OurMessage = (struct OurStructure*)AllocMem (sizeof(OurStructure), MEMF_PUBLIC|MEMF_CLEAR))
/* Initialize the structure after*/


Ahhh pointer magic then :-) :pint:

Offline bloodline

  • Master Sock Abuser
  • Hero Member
  • *****
  • Join Date: Mar 2002
  • Posts: 12114
    • Show all replies
    • http://www.troubled-mind.com
It's a curious thought that AOS doesn't have any memory sharing functions... with semaphor protection etc... I suppose one could use "files" on the Ram: device... but that sounds too Unixie to me :-D