www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - real time

reply Frank Benoit <frank nix.de> writes:
Hello ng

* Is it possible to write kernel modules in D?

* Is it possible to write realtime apps in D?
  For example using the rtai for linux.

* If any, what are the missing requirements?

Frank
Dec 07 2005
next sibling parent Dave <Dave_member pathlink.com> writes:
In article <dn67ub$1u3c$1 digitaldaemon.com>, Frank Benoit says...
Hello ng

* Is it possible to write kernel modules in D?

* Is it possible to write realtime apps in D?
  For example using the rtai for linux.

* If any, what are the missing requirements?

Frank
Perhaps these will help: http://digitalmars.com/d/iasm.html http://digitalmars.com/d/memory.html http://digitalmars.com/d/interfaceToC.html
Dec 08 2005
prev sibling next sibling parent Thomas Kuehne <thomas-dloop kuehne.cn> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Frank Benoit schrieb am 2005-12-07:
 Hello ng

 * Is it possible to write kernel modules in D?
http://dkernel.kuehne.cn/hello.d Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFDmgiX3w+/yD4P9tIRAl4oAKCMOXC9gmbLXGCPPz72/Uo2lBpILACfZoQU dB9zT9GgCoC3fhiyQi1xIjQ= =7P5z -----END PGP SIGNATURE-----
Dec 09 2005
prev sibling parent reply Frank Benoit <frank nix.de> writes:
Thanks for the replies.


it seems to me, D can be an alternative to C/C++ in realtime programming.

From http://www.digitalmars.com/d/memory.html#realtime
"The most reliable way to guarantee latency is to preallocate all data
that will be needed by the time critical portion."

What are the things to avoid?
- every new
- dynamic arrays in general?
- slicing arrays
- concatenating strings?
- ...?

Can I make a dynamic allocation protection. A mechanism that throws an
exception if the programm makes a direkt or indirekt allocation.

The disable/enable of the gc, does only throw outofmemory. Is there a
possibility to get the exception at the first unwanted allocation try?

void InterruptServiceRoutine()
{
	std.gc.disable();
	
	try
	{
		/// all the realtime things
	}
	catch( OutOfMemory oom )
	{
	}
	finally
	{
		std.gc.enable();
	}
}

Does the gc and D work with RTAI Lxrt?
http://www.rtai.org/documentation/magma/html/api/whatis_lxrt.html
There is this:

"They must be POSIX real time Linux processes locked into memory using
SCHED_FIFO. Thus their memory must be pre grown to its maximum extension
and completely locked in memory."

I do not understand that completely, especially not the consequences for
D and the gc.

Frank
Dec 09 2005
parent Dave <Dave_member pathlink.com> writes:
In article <dndh3a$289t$1 digitaldaemon.com>, Frank Benoit says...
Thanks for the replies.


it seems to me, D can be an alternative to C/C++ in realtime programming.

From http://www.digitalmars.com/d/memory.html#realtime
"The most reliable way to guarantee latency is to preallocate all data
that will be needed by the time critical portion."

What are the things to avoid?
- every new
- dynamic arrays in general?
- slicing arrays
- concatenating strings?
- ...?
I would say the basic rules would be: - avoid the built-in new (you can override it - that's covered in the docs.). - use static arrays instead of the built-in dynamic arrays. The compiler disallows concatenation and - don't use .dup on any type of array. Slices return a reference to the array and, for D style arrays, also modify the length member. But they should not allocate memory.
Can I make a dynamic allocation protection. A mechanism that throws an
exception if the programm makes a direkt or indirekt allocation.

The disable/enable of the gc, does only throw outofmemory. Is there a
possibility to get the exception at the first unwanted allocation try?

void InterruptServiceRoutine()
{
	std.gc.disable();
	
	try
	{
		/// all the realtime things
	}
	catch( OutOfMemory oom )
	{
	}
	finally
	{
		std.gc.enable();
	}
}

Does the gc and D work with RTAI Lxrt?
http://www.rtai.org/documentation/magma/html/api/whatis_lxrt.html
There is this:

"They must be POSIX real time Linux processes locked into memory using
SCHED_FIFO. Thus their memory must be pre grown to its maximum extension
and completely locked in memory."

I do not understand that completely, especially not the consequences for
D and the gc.

Frank
Dec 10 2005