
SimTOS v0.1
-----------

SimTOS is a library which mimics the services provided by the MTOS-UX 
operating system from IPI. The main motivation for writing this library 
is to provide a means to develop embedded software under cross platform
development before the hardware is available. This can significantly
reduce the development time for a system.

In summary, the library is simply a wrapper around the Pthreads library
as supplied by the Florida State University under the terms of the
GNU LGPL. Therefore, before compiling this library, you will need to
obtain a copy of the pthreads library from:

	ftp://ftp.cs.fsu.edu/pub/PART/pthreads.tar.gz

To compile this library for SimTOS, you need to edit the file internals.h.
In this file, change MAX_PRIORITY to 255. The reason for this is
because MTOS-UX has 255 priority levels instead of the standard 101.

Next you will need to do some changes in the source files. I'm not
sure whether the following problem still applies, but you may find
that the file signal.c fails to compile under the Linux platform. There
are two errors in the conditional compilation flags.

At line ~585, it reads

    #if defined(IO) && !defined(__FreeBSD__) && defined(_M_UNIX) \
                                                && !defined(__dos__)
        else if (sig == SIGIO && aio_handle())
            return;
    #endif /* IO && !__FreeBSD__ && !_M_UNIX && !__dos__ */
        else if (!(p = pthread_q_all_find_receiver(&all, sig))) {
        if (!sigismember(&pending_signals, sig)) {
            sigaddset(&pending_signals, sig);
            pending_code[sig] = code;
        }

The #if define ... should read

    #if defined(IO) && !defined(__FreeBSD__) && defined(_M_UNIX) \
                         && !defined(__dos__) && !defined(__linux__)
                                                ^^^^^^^^^^^^^^^^^^^^

Similarly, at line ~2260, the same change applies


   #if defined(IO) && !defined(__FreeBSD__) && !defined(_M_UNIX) \
                                                && !defined(__dos__)
   /*
    * fds_update - update fields of file descriptors
    */
   static int fds_update(lrfds, lwfds, lefds, grfds, gwfds, gefds, width)
       fd_set *lrfds, *lwfds, *lefds, *grfds, *gwfds, *gefds;
       int width;

The #if define ... should read

   #if defined(IO) && !defined(__FreeBSD__) && defined(_M_UNIX) \
                          && !defined(__dos__) && !defined(__linux__)
                                                ^^^^^^^^^^^^^^^^^^^^

These should fix the problems with compiling the library and you can
then follow the instructions to install the threads library before
compiling SimTOS.


To compile SimTOS, simply type 

    % make

The resultant library is libsimtos.a which you can use to link into
your application for host testing and debugging. Note that you need to
include the following libraries when linking.

	-lgthreads	Threads library
	-lmalloc	Threads version of malloc library
	-lm		Math library
	-lsimtos	SimTOS library

If you are using MTOS in your target environment, then you may want to
use the mtosux.h header as supplied by IPI. As this is commercial
software, I can not distribute it, but only provide the enclosed
version.

If you are using the original mtosux.h header, you'll find that
you need to put conditional compilation preprocessor defines around
the definitions

	typedef void	(* caddr_t)();	/* code address */
	typedef LONG	pid_t;		/* processor id: -1, or 0 to 15 */
	
Both are defined in the linux system headers and to get around this,
I used

	#ifndef _LINUX_TYPES_H
	typedef void	(* caddr_t)();	/* code address */
	typedef LONG	pid_t;		/* processor id: -1, or 0 to 15 */
	#endif

You will also need to define the following at the end of the header
to avoid conflict with the standard library definitions.

	#define pause  ux_pause
	#define getuid ux_getuid

The last point is that you must add either _MC68, _I86, or _I386 to the
CFLAGS in the Makefile in order to switch between the different targets
two want to simulate. Read the descriptions at the top of the header.

If you don't have MTOS, then I'm assuming you are using it for
educational purposes. I think MTOS-UX is a good introduction to
students who are learning about real time operating systems. There is
also a book on this topic named "An Implementation Guide to a Real
Time Operating System" by David Ripps, the founder of IPI, which
describes in detail the inner mechanisms of the operating system.

The library is fairly complete but it does not implement all services.
For example, signals are not implemented yet, mainly because I don't
use this feature often. See the list of function prototypes in this
provided mtosux.h file for what is implemented.

Just for the record, I am using

	Linux kernel 2.0.7
	GCC 2.7.2
	PThreads 3.1 (As distributed on 10/11/96)

If you have successfully compile this library or you are having
problems with it, please contact me via email. I'll do my best to
solve your problem.

Depending on the demand, I am planning to fully implement some
of the coordination parameters supported by MTOS-UX. Please
let me know If you have any other suggestions.


Daniel Wu (dwu@linus.socs.uts.edu.au)
December 1996
