view TaskManager/kernel/ppe/CpuThreads.h @ 1179:5393bebe0956 draft

CpuThreads update
author Daichi TOMA
date Tue, 21 Jun 2011 19:50:53 +0900
parents 730f5e5c8351
children fa380908f801
line wrap: on
line source

#ifndef INCLUDED_CPU_THREADS
#define INCLUDED_CPU_THREADS

#include <pthread.h>
#include <semaphore.h>
#include "Threads.h"
#include "TaskManagerImpl.h"
#include "MainScheduler.h"

typedef struct cpu_arg {
    int cpuid;
    // should be syncrhonized
    MainScheduler *scheduler;
    TaskManagerImpl *manager;
} cpu_thread_arg_t;

class CpuThreads : Threads {
public:
    /* constructor */
    CpuThreads(int num = 1, int start_id = 0);
    ~CpuThreads();
    static void *cpu_thread_run(void *args);

    /* functions */
    virtual void init();
    virtual int get_mail(int speid, int count, memaddr *ret); // BLOCKING
    virtual int has_mail(int speid, int count, memaddr *ret); // NONBLOCK
    virtual void send_mail(int speid, int num, memaddr *data); // BLOCKING
    virtual void add_output_tasklist(int command, memaddr buff, int alloc_size);

private:
    /* variables */
    pthread_t *threads;
    cpu_thread_arg_t *args;
	sem_t *sem;
    int cpu_num;
    int id_offset;
};

typedef CpuThreads *CpuThreadsPtr;

#endif