MentOS  0.8.0
The Mentoring Operating System
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Classes | Macros | Functions | Variables
msg.c File Reference

Classes

struct  msq_info_t
 Message queue management structure. More...
 

Macros

#define __DEBUG_HEADER__   "[IPCmsg]"
 Change header.
 
#define __DEBUG_LEVEL__   LOGLEVEL_NOTICE
 Set log level.
 

Functions

static msq_info_t__msq_info_alloc (key_t key, int msqflg)
 Allocates the memory for message queue structure. More...
 
static void __msq_info_dealloc (msq_info_t *msq_info)
 Frees the memory of a message queue management structure. More...
 
static msq_info_t__list_find_msq_info_by_id (int msqid)
 Searches for the message queue with the given id. More...
 
static msq_info_t__list_find_msq_info_by_key (key_t key)
 Searches for the message queue with the given key. More...
 
static void __list_add_msq_info (msq_info_t *msq_info)
 Adds the structure to the global list. More...
 
static void __list_remove_msq_info (msq_info_t *msq_info)
 Removes the structure from the global list. More...
 
static void __msq_info_push_message (msq_info_t *msq_info, struct msg *message)
 Pushes a messages inside the message queue. More...
 
static void __msq_info_remove_message (msq_info_t *msq_info, struct msg *message)
 Removes the message from the message queue. More...
 
int msq_init (void)
 Iinitializes the message queue system. More...
 
int sys_msgget (key_t key, int msgflg)
 
int sys_msgsnd (int msqid, const void *msgp, size_t msgsz, int msgflg)
 
ssize_t sys_msgrcv (int msqid, void *msgp, size_t msgsz, long msgtyp, int msgflg)
 
int sys_msgctl (int msqid, int cmd, struct msqid_ds *buf)
 
ssize_t procipc_msg_read (vfs_file_t *file, char *buf, off_t offset, size_t nbyte)
 Read function for the proc system. More...
 

Variables

static int __msq_id = 0
 A value to compute the message queue ID.
 
list_head msq_list
 List of all current active Message queues.
 

Detailed Description

Function Documentation

◆ __list_add_msq_info()

static void __list_add_msq_info ( msq_info_t msq_info)
inlinestatic

Adds the structure to the global list.

Parameters
msq_infothe structure to add.

◆ __list_find_msq_info_by_id()

static msq_info_t* __list_find_msq_info_by_id ( int  msqid)
inlinestatic

Searches for the message queue with the given id.

Parameters
msqidthe id we are searching.
Returns
the message queue with the given id.

◆ __list_find_msq_info_by_key()

static msq_info_t* __list_find_msq_info_by_key ( key_t  key)
inlinestatic

Searches for the message queue with the given key.

Parameters
keythe key we are searching.
Returns
the message queue with the given key.

◆ __list_remove_msq_info()

static void __list_remove_msq_info ( msq_info_t msq_info)
inlinestatic

Removes the structure from the global list.

Parameters
msq_infothe structure to remove.

◆ __msq_info_alloc()

static msq_info_t* __msq_info_alloc ( key_t  key,
int  msqflg 
)
inlinestatic

Allocates the memory for message queue structure.

Parameters
keyIPC_KEY associated with message queue.
msqflgflags used to create message queue.
Returns
a pointer to the allocated message queue structure.

◆ __msq_info_dealloc()

static void __msq_info_dealloc ( msq_info_t msq_info)
inlinestatic

Frees the memory of a message queue management structure.

Parameters
msq_infopointer to the message queue management structure.

◆ __msq_info_push_message()

static void __msq_info_push_message ( msq_info_t msq_info,
struct msg *  message 
)
inlinestatic

Pushes a messages inside the message queue.

Parameters
msq_infothe structure that will contain the message.
messagethe message to push.

◆ __msq_info_remove_message()

static void __msq_info_remove_message ( msq_info_t msq_info,
struct msg *  message 
)
inlinestatic

Removes the message from the message queue.

Parameters
msq_infothe structure that contains the message.
messagethe message to remove.

◆ msq_init()

int msq_init ( void  )

Iinitializes the message queue system.

Returns
0 on success, 1 on failure.

◆ procipc_msg_read()

ssize_t procipc_msg_read ( vfs_file_t file,
char *  buf,
off_t  offset,
size_t  nbyte 
)

Read function for the proc system.

Parameters
fileThe file.
bufBuffer where the read content must be placed.
offsetOffset from which we start reading from the file.
nbyteThe number of bytes to read.
Returns
The number of red bytes.