Welcome, Guest. Please login or register.

Author Topic: Fake seglist in C...  (Read 7167 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline Thomas

Re: Fake seglist in C...
« on: August 07, 2007, 06:00:33 PM »
@golem: no cracking, just run a subroutine of your program (instead of an externally loaded program) as a seperate thread.

@Jose: the opcode for JMP is 0x4EF9. Here is an example: http://thomas-rapp.homepage.t-online.de/examples/multi13.c

But please note that this is Kickstart 1.3 and below style of programming. Starting with Kickstart 2.0 you can use CreateNewProc with NP_Entry and don't need to fake anythimg. The same example for Kick 2.0+: http://thomas-rapp.homepage.t-online.de/examples/multi.c

An important note when working with multiple threads is that ANSI runtime routines, especially buffered I/O (printf etc.) are not thread-safe and can give various strange results. You should use the AmigaDOS equivalents (e.g. Printf with a capital "P") instead.

Bye,
Thomas

Offline Thomas

Re: Fake seglist in C...
« Reply #1 on: March 07, 2013, 09:18:21 PM »
The process stucture contains a message port (pr_MsgPort) which can be used for sending an initial message. Check how the startup code for Workbench programs receives the WBStartup message, that's just the same.

But be warned: this port can be used only in the initialisation phase of your new process. Once you want to use DOS functions, you must leave this port alone because DOS uses it for its communication.

I could make an example tomorrow if I find some spare time.

Offline Thomas

Re: Fake seglist in C...
« Reply #2 on: March 09, 2013, 01:29:43 PM »
Quote from: nyteschayde;728626
Thomas did you get a chance to write a sample?


I wish you had more patience ;-)

Here are two examples, a third has yet to come:

http://thomas-rapp.homepage.t-online.de/examples/multi1.c
http://thomas-rapp.homepage.t-online.de/examples/multi2.c

The first is a simple one-shot which does its job in the background without any further communication and only replies when it is finished. The protocol used is very similar to how Workbench runs programs, sends arguments to them and waits until they are finished.

The second one is similar but it sends progress reports to the main task.

The third will be more complex. It should be a kind of server which receives commands and responds to them and stays up until it receives the stop command.

These three examples should cover most cases where you'd use multitasking in an application program.



Quote
Also would you like me to take this offline given your email address is posted?


As you can see from the first page of this thread, I am not all knowing. So it's better to stay here and give others the opportunity to correct me.

Offline Thomas

Re: Fake seglist in C...
« Reply #3 on: March 10, 2013, 02:16:51 PM »