Unison Help
- Unison Kernel
- Pthreads
- pthread_create()
- pthread_exit()
- pthread_self()
- pthread_equal()
- pthread_join()
- pthread_detach()
- pthread_setschedparam()
- pthread_getschedparam()
- pthread_attr_init()
- pthread_attr_destroy()
- pthread_attr_setstackaddr()
- pthread_attr_getstackaddr()
- pthread_attr_setstacksize()
- pthread_attr_getstacksize()
- pthread_attr_setschedparam()
- pthread_attr_getschedparam()
- pthread_attr_setdetachstate()
- pthread_attr_getdetachstate()
- pthread_stackinfo()
- pthread_setprio()
- pthread_getprio()
- sched_get_priority_max()
- sched_get_priority_min()
- sched_yield()
- Pthread Cancellation
- Mutex
- Semaphores
- Message Queues
- Conditional Variables
- Barriers
- Timers
- Clocks
- Memory Allocation
- Rendezvous
- Interrupts
- Directory Services
- Miscellaneous
- Pthreads
- Unison I/O Library
- Unison STDIO Library
- STDIO Library Calls
- clearerr()
- dprintf()
- fclose()
- fdopen()
- feof()
- ferror()
- fileno()
- fflush()
- fgetc()
- fgetpos()
- fgets()
- fopen()
- fprintf()
- fputc()
- fputs()
- fread()
- freopen()
- fscanf()
- fseek()
- fseeko()
- fsetpos()
- ftell()
- ftello()
- fwrite()
- getc()
- getc_unlocked()
- getchar()
- getchar_unlocked()
- getdelim()
- getline()
- gets()
- get_stderr_ptr()
- get_stdin_ptr()
- get_stdout_ptr()
- noperprintf()
- perprintf()
- perror()
- posix_compat()
- printf()
- putc()
- putc_unlocked()
- putchar()
- putchar_unlocked()
- puts()
- remove()
- rewind()
- scanf()
- setbuf()
- setvbuf()
- snprintf()
- sprintf()
- sscanf()
- stderr_init()
- stderr_close()
- stdin_init()
- stdin_close()
- stdout_init()
- stdout_close()
- vdprintf()
- vscanf()
- vsscanf()
- vfscanf()
- vprintf()
- vsnprintf()
- vsprintf()
- vfprintf()
- ungetc()
- Do-nothing Stubs
- STDIO Library Calls
- Unison LIBC Library
- Unison I/O Servers
- Graphics, Camera, Video, Audio
- Network Protocols
- TCP and UDP Server - tcpd
- DHCP Client Service - dhcp client
- DHCP Server - dhcpd
- Telnet Server - telnetd
- Tiny FTP Server - tftpd
- Point to Point - pppd
- Network Translation - NAT with PAT
- Firewall
- Tiny HTTP Server - thttpd
- Tiny HTTP Server with TLS
- POP3 Server
- Simple Mail Transfer Protocol Services (SMTP)
- Bootp Protocol
- File Transfer Protocol Server (FTP)
- File Transfer Client Services
- RPC / XDR
- DNS Client
- HTTP/HTTPS Client
- REST Client
- AutoIP Service - autoip client
- mDNS server - mdnsd
- SNTP Client
- SNMP Agent - Snmpd server
- SSL/TLS library
- SSH server
- IP security
- Power Control
- Serial I/O
- System Services
- Universal Serial Bus (USB)
- Wireless
- Remedy Tools for Unison
1.11.3.mr_receive() #
NAME
mr_receive – receive a message or signal
SYNOPSIS
#include <mrendez.h>
- pthread_t mr_receive( void *rqst,
- BitMask portmask, BitMask sigmask, int *outport,
- struct timespec *timeout);
DESCRIPTION
The mr_receive() primitive is used to receive messages and/or signals from threads. ISRs can also send signals. If both signals and messages are available at the time of the call, the highest priority signal is accepted; otherwise, the first suitable signal or message is accepted.
A message can be sent to the calling thread via the mr_send() primitive. The message is received into the area pointed to by request. Note that the sending thread then blocks until a reply message is received. This reply message is sent by the receiver using mr_reply().
The portmask implements a selective accept mechanism using the ports defined by mr_init() and the signals availble to the thread. This argument is a 32 bit port mask indicating which ports the thread is willing to accept a message through. The ports are numbered 0 through 31. To accept from port n, bit (1 << n ) must be set in the portmask.
The mr_init() function must be called before mr_receive can be called. The ports argument to mr_init() limits how many ports can actually be received through. It is not an error to set a port in the portmask higher than ports, but no messages will come through the port.
A signal may be sent to the calling thread by threads or ISRs via the mr_sigpost() primitive.
The sigmask implements part of the selective accept mechanism. This argument works just like the portmask described above. All threads can accept all 32 signals, there is no limit as in ports.
The actual port or signal received is set in outport. The value returned in outport is the port or signal number, not it’s mask. The argument outport may be NULL if this value is not needed.
The timeout argument specifies the time that the caller is willing to wait before the system should indicate that the no signal or message was received. The define FOREVER can be defined if the call should never timeout.
NOTES
Signals of each value are not queued for the thread by the system; therefore, a thread cannot have more than one outstanding signal of each value at any time. The lower a signal’s value, the higher its priority; the system does not interpret the value of signals in any other way.
Signals are not to be confused with POSIX signals. They are used to transmit binary events from ISRs to threads and other OS events to threads without blocking the sender. They only occur once – multiple occurances of signals register as a single binary event.
The contents of the rqst are undefined when a signal is received.
There is no guarantee as to which order messages are received from multiple ports, if more than one port contains a message, other than that a fair scheduling algorithm is implemented. Messages are queued FIFO within each particular port.
The first 16 bits of the rqst argument are taken to be the maximum size, in bytes, of the message which may be written into rqst. The lesser of this size and the size obtained from the sender’s rqst argument represents the number of bytes actually copied by the system. Note that since the size bytes are the first two bytes transferred, it is possible to determine if the rqst was truncated.
RETURN VALUES
If a signal is received, mr_receive() returns INTERRUPT_ID. If a message is received, mr_receive returns the sending threads’s id. A zero is returned if the call failed.
The number of the signal received, or the number of the port through which the message was received, is returned in outport.
The sender’s request, if any, is returned in the area pointed to by rqst.
ERRORS
- ENOENT
- The receiveing thread has not called mr_init().
- ETIMEDOUT
- The calling threads’s receive request could not be fulfilled within the time period specified by timeout.