view TaskManager/kernel/ppe/CpuThreads.h @ 1531:4443d59a8210 draft

SDL.h in main.cc
author yuhi@cr.ie.u-ryukyu.ac.jp
date Fri, 07 Dec 2012 15:46:27 +0900
parents 622a7d053537
children e8c9a7099bcc
line wrap: on
line source

#ifndef INCLUDED_CPU_THREADS
#define INCLUDED_CPU_THREADS

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

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

class GpuThreads;

class CpuThreads : public Threads {
 public:
    /* constructor */
    CpuThreads(int num = 1, int useRefDma = 0, 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);
    virtual int is_gpu(int cpuid);

private:
    /* variables */
    pthread_t *threads;
    cpu_thread_arg_t *args;
    SemPtr wait; //スレッド生成時の待ち用
    int cpu_num;
    int use_refdma;
    int id_offset;
#ifdef __CERIUM_GPU__
    GpuThreads *gpu;
#endif
};

#endif