/*
    TMThread.h, Copyright  (c) by Christian Conrad,
    Swiss Federal Institute of Technology,
    Computer Engineering and Networks Laboratory.
 
    TOPSY -- A Teachable Operating System.
             Implementation of a tiny and simple
             micro kernel for teaching purposes.
 
    For further information, please visit http://www.tik.ee.ethz.ch/~topsy
 
    This software is provided under the terms of the GNU General Public Licence.
 
    A full copy of the GNU GPL is provided in the file COPYING found in the 
    development root of Topsy.
*/
/*
	
	File:                  $Source: /home/ruf/cvs_Topsy/cvs/Topsy/Threads/TMThread.h,v $
 	Author(s):             Christian Conrad
 	Affiliation:           ETH Zuerich, TIK
 	Version:               $Revision: 2935 $
 	Creation Date:         
 	Last Date of Change:   $Date: 2007-03-21 11:58:17 +0100 (Mit, 21 Mär 2007) $      by: $Author: baderma $
	
*/

#ifndef __TMTHREAD_H
#define __TMTHREAD_H

#include "tm-include.h"
#include "Lock.h"

extern Lock threadLock;

/*
 * Thread interface functions
 */
ThreadId threadStart( ThreadMainFunction fctnAddr,
                      ThreadArg parameter, AddressSpace mode,
                      char *name, ThreadId parentId, ThreadId destPD,
                      ThreadPriority priority, ThreadId desId);
void threadExit( ThreadId threadId);
void threadYield(void);
Error threadKill( ThreadId id, ThreadId killerId);
Error threadInfo( ThreadId id, ThreadId aboutId,
                  ThreadInfoKind kind, ThreadInfo* infoptr, long int values[]);

ThreadId getThPdomId(ThreadId desId);
int threadBuild( ThreadId id,
                 ThreadId pdId,
                 ThreadId callerId,
                 char* name,
                 ProcContextPtr contextPtr,
                 Address stackBaseAddress,
                 Address stackBaseMappedAt,
                 unsigned int stackSize,
                 ThreadMainFunction mainFunction,
                 ThreadArg parameter,
                 AddressSpace space,
                 Thread* threadPtr,
                 ThreadPriority priority,
                 ThreadPermission permission);

ThreadId startMinimalIdleThread(void);
Thread* getTHbyId(ThreadId thId);
void threadStructDisplay(Thread *threadPtr);

#endif
