view TaskManager/kernel/ppe/MailManager.h @ 1180:2e20d2bb55c6 draft

change mailmanager to mail on semaphore
author Daichi TOMA
date Sat, 25 Jun 2011 09:39:45 +0900
parents 1b9418af3127
children 4c209dd223cd
line wrap: on
line source

#ifndef INCLUDED_MAIL_MANAGER
#define INCLUDED_MAIL_MANAGER

#include <pthread.h>
#include "types.h"
#include "Sem.h"

class MailManager {
public:
    /* constructor */
    MailManager(unsigned int qsize = 32) ;

    ~MailManager();

    /* functions */
    void send(memaddr data);
    memaddr recv();
    int count();

private:
    /* variables */
    memaddr *queue;
    pthread_mutex_t *mutex_s;
    pthread_mutex_t *mutex_r;
    SemPtr remain;
    unsigned int size;
    unsigned int read;
    unsigned int write;
    unsigned int mask;

    void calc_mask(unsigned int qsize);
    void extend();
}  ;

typedef MailManager *MailManagerPtr;

#endif