home *** CD-ROM | disk | FTP | other *** search
- NAME
- MosInit - Initialize MOS environment from application.
-
- SYNOPSIS
-
- #include <mos.h>
-
- SHORT
- MosInit()
-
- DESCRIPTION
-
- MOS internal variables and data structures are initialized
- for subsequent application calls to MOS functions.
-
-
- C_STATUS = MosInit();
-
-
- RESOURCE NAME
-
- MOS.LIB
-
- DIAGNOSTICS
-
- C_OK = initialized successful
- C_NOTOK = initialization unsuccessful
-
-
- NAME
- MosProcCreate - create a procedure in the MOS environment.
-
- SYNOPSIS
-
- #include <mos.h>
-
- SHORT
- MosProcCreate(pProc,szProcName,sPriority)
- SHORT (*pProc)(PROC_P psProc);
- PCHAR szProcName;
- SHORT sPriority;
-
- DESCRIPTION
-
- C function pointed to by pProc is announced to the MOS
- environment as a new process. It is named by szProcName
- and given sPriority process priority. All functions used
- as MOS processes as of type SHORT (*) (PROC_P). The PROC_P
- is a pointer to a MOS specific process structure.
-
- RESOURCE NAME
-
- MOS.LIB
-
- DIAGNOSTICS
-
- C_OK - initialization successful.
- !C_OK - error
-
-
- NAME
- MosProcTerm - removes process from MOS environment.
-
- SYNOPSIS
-
- #include <mos.h>
-
- SHORT
- MosProcTerm(pProc)
- PROC_P pProc;
-
- DESCRIPTION
-
- MOS will remove from all data structures the process described
- by pProc. MosProcTerm() is usually called by the terminating
- process itself.
-
- RESOURCE NAME
-
- MOS.LIB
-
- DIAGNOSTICS
-
- C_OK = process terminated
- !C_OK = error
-
- NAME
- MosScheduler - The MOS process scheduler.
-
- SYNOPSIS
-
- #include <memincs.h>
-
- SHORT
- MosScheduler()
-
- DESCRIPTION
-
- It is the MOS process scheduler (multi-tasker) and is called
- when all initial processes have been created. It does not return
- until all processes (other than the NULL process) have terminated.
-
-
- C_STATUS = MosInit();
-
- C_STATUS = MosProcCreate(TestProc,"TEST_PROC,10);
-
- C_STATUS = MosScheduler();
-
-
- RESOURCE NAME
-
- MOS.LIB
-
- DIAGNOSTICS
-
- C_OK - always returned
-
-
- NAME
- MemSemInit - initialize a new semaphore
-
- SYNOPSIS
-
- #include <mos.h>
-
- SHORT
- MosSemInit(pstProc,pcSemName,psSemHandle)
- PROC_P pstProc;
- PCHAR pcSemName;
- PSHORT psSemHandle;
-
- DESCRIPTION
-
- Process pstProc creates semaphore with name pcSemName.
- A handle to the newly created semaphore is returned in
- psSemHandle.
-
- RESOURCE NAME
-
- MOS.LIB
-
- DIAGNOSTICS
-
- C_OK - semaphore created
- !C_OK - error
-
-
- NAME
- MosSemTerm - terminate a semaphore
-
- SYNOPSIS
-
- #include <mos.h>
-
- SHORT
- MosSemTerm(pstProc,pcSemName,sSemHandle)
- PROC_P pstProc;
- PCHAR pcSemName;
- SHORT sSemHandle;
-
- DESCRIPTION
-
- Removes a semaphore from MOS memory when it is no longer
- needed.
-
- MOS process pstProc requests termination of semaphore
- named pcSemName with handle sSemHandle.
-
- RESOURCE NAME
-
- MOS.LIB
-
- DIAGNOSTICS
-
- C_OK - semaphore terminated
-
-
- NAME
- MosSemWait - wait for ownership of a semaphore
-
- SYNOPSIS
-
- #include <mos.h>
-
- SHORT
- MosSemWait(pstProc,sSemHandle)
- PROC_P pstProc;
- SHORT sSemHandle;
-
- DESCRIPTION
-
- Process pstProc requests ownership to semaphore sSemHandle.
- If a semaphore is currently in use by another process, the
- requesting process will be placed in a semaphore-waiting
- queue. All queued semaphore requests are in FIFO order.
- If a process is placed in the wait queue, it is placed back
- on the ready queue with ownership of the semaphore.
-
-
-
- MosSemInit(pstProc,"Sem1",&sSemHandle);
-
- MosSemWait(pstProc,sSemHandle);
-
- ... other processing which required semaphore ...
-
- MosSemSignal(pstProc,sSemHandle);
-
-
- If MosSemWait() returns MOS_PROC_SUSPENDED, this means that the
- semaphore was not available and the process has been suspeneded.
- The process must immediately C_LEAVE(C_OK).
-
-
-
- RESOURCE NAME
-
- MOS.LIB
-
- DIAGNOSTICS
-
- C_OK - always returned
-
-
- NAME
- MosSemSignal - release ownership of semaphore
-
- SYNOPSIS
-
- #include <mos.h>
-
- SHORT
- MosSemSignal(pstProc,sSemHandle)
- PROC_P pstProc;
- SHORT sSemHandle;
-
- DESCRIPTION
-
- Process pstProc releases ownership of a semaphore sSemHandle.
- Semaphore sSemHandle is then available for another process
- waiting for it with a MosSemWait().
-
-
- RESOURCE NAME
-
- MOS.LIB
-
- DIAGNOSTICS
-
- C_OK - always returned
-
- NAME
- MosSemClear - clears a semaphore and releases it
-
- SYNOPSIS
-
- #include <mos.h>
-
- SHORT
- MosSemClear(pstProc,sSemHandle)
- PROC_P pstProc;
- SHORT sSemHandle;
-
- DESCRIPTION
-
- Process pstProc clears semaphore sSemHandle.
-
- MosSemClear is very similar to MosSemSignal but is a
- different semaphore scheme. MosSemWait/MosSemSignal
- provide a mechanism for resource exclusivity. MosSemClear/
- MosSemSet provide a mechanism for process synchronization.
- A synchronizing semaphore scheme is implemented in MFM.
-
-
-
- RESOURCE NAME
-
- MOS.LIB
-
- DIAGNOSTICS
-
- C_OK - always returned
-
-
- NAME
- MosSemSet - set semaphore to 1
-
- SYNOPSIS
-
- #include <mos.h>
-
- SHORT
- MosSemSet(pstProc,sSemHandle)
- PROC_P pstProc;
- SHORT sSemHandle;
-
- DESCRIPTION
-
- Process pstProc sets semaphore sSemHandle. MosSemSet is used
- in conjunction with MosSemClear.
-
- RESOURCE NAME
-
- MOS.LIB
-
- DIAGNOSTICS
-
- C_OK - always returned
-
-
- NAME
- MosCurTime - get the current time
-
- SYNOPSIS
-
- #include <mos.h>
-
- LONG
- MosCurTime()
-
- DESCRIPTION
-
- Returns the current time in seconds since Jan 1, 1970.
-
- DIAGNOSTICS
-
- Current time returned.
-
-
- NAME
- MosSleep - a process puts itself to sleep
-
- SYNOPSIS
-
- #include <mos.h>
-
- SHORT
- MosSleep(pstProc)
- PROC_P pstProc;
-
- DESCRIPTION
-
- Process pstProc places itself on the sleep queue. Before the
- MosSleep call, the process will set its wakeup time with
- MOS_SET_WAKE_TIME.
-
- RESOURCE NAME
-
- MOS.LIB
-
- DIAGNOSTICS
-
- C_OK - always returned
-
-
- NAME
- MosGetPidByName - get the process id of another process
-
- SYNOPSIS
-
- #include <mos.h>
-
- SHORT
- MosGetPidByName(pcName,psPid)
- PCHAR pcName;
- PSHORT psPid;
-
- DESCRIPTION
-
- Process named pcName is searched for in the MOS environment.
- Parameter psPid will be set to the process id of the process
- if found or MOS_PROC_NULL if the process does not exist.
-
- RESOURCE NAME
-
- MOS.LIB
-
- DIAGNOSTICS
-
- C_OK - always returned
-
-
-
- NAME
- MosMsgWrite - write a message to another processes message queue
-
- SYNOPSIS
-
- #include <mos.h>
-
- SHORT
- MosMsgWrite(pstProc,pcData,sLen,sTargetProcId)
- PROC_P pstProc;
- PCHAR pcData;
- SHORT sLen;
- SHORT sTargetProcId;
-
- DESCRIPTION
-
- Process pstProc sends data pcData for length sLen to process
- sTargetProcId. The target process id can be found with
- MosGetPidByName.
-
- RESOURCE NAME
-
- MOS.LIB
-
- DIAGNOSTICS
-
- C_OK - message delivered
- !C_OK - error
-
-
- NAME
- MosMsgRead - read a message on the current processes message queue
-
- SYNOPSIS
-
- #include <mos.h>
-
- SHORT
- MosMsgRead(pstProc,ppstMsg)
- PROC_P pstProc;
- MSG_P * ppstMsg;
-
- DESCRIPTION
-
- Process pstProc attempts to read a message on its message queue.
- Parameter ppstMsg is based on the MSG_T structure:
-
- struct MSG_S
- {
- SHORT sSendPid; /* Pid of sender */
- SHORT sDestPid; /* Pid of receiver */
- SHORT sLen; /* length of message/data */
- PCHAR pcData; /* ptr to data */
- };
-
- typedef struct MSG_S MSG_T;
- typedef MSG_T * MSG_P;
-
-
- The pcData pointer can be cast to another structure based on
- whatever scheme the application requires. The process id
- of the sender can also be used if multiple application
- messages exist.
-
- Note: If a message does not exist, the process will be
- placed in a wait state. The process can check the state
- of the message queue with the MOS_MSG_WAITING macro before
- making this call. MOS_MSG_WAITING will return C_TRUE if a message
- if available.
-
-
- RESOURCE NAME
-
- MOS.LIB
-
- DIAGNOSTICS
-
- C_OK - message read
- MOS_PROC_SUSPEND - no message, process suspended.
-
-
- NAME
- MosEventCreate - create a MOS event handler
-
- SYNOPSIS
-
- #include <mos.h>
-
- SHORT
- MosEventCreate(pCheckProc,pEventProc,szEventName,sEventPriority)
- SHORT (*pCheckProc)();
- SHORT (*pEventProc)(PROC_P);
- PCHAR szEventName;
- SHORT sPriority;
-
- DESCRIPTION
-
-
- Mos events are defined by the pCheckProc returning TRUE.
- The pCheckProc defines the nature of the event by any code
- which is in it. Event checking is performed by the Mos
- scheduler every time before a Mos process is switched to.
- When an event pCheckProc returns TRUE, the pEventProc is
- placed on the Mos ready queue.
-
- The pEventProc (all event procs should be given higher
- priorities the other Mos procs) will then send a Mos message
- to a Mos proc acting as the 'server' for that event.
-
- RESOURCE NAME
-
- MOS.LIB
-
- DIAGNOSTICS
-
- C_OK - initialization successful.
- !C_OK - error
-
-
- NAME
- MosProcTerm - removes process from MOS environment.
-
- SYNOPSIS
-
- #include <mos.h>
-
- SHORT
- MosEventTerm(pProc)
- PROC_P pProc;
-
- DESCRIPTION
-
- MOS will remove from all data structures the event described
- by pProc. MosProcTerm() is usually called by the terminating
- Event proc itself.
-
- RESOURCE NAME
-
- MOS.LIB
-
- DIAGNOSTICS
-
- C_OK = process terminated
- !C_OK = error
-
-