view example/fileread/ppe/Read.cc @ 1808:c25aa7edd1ba draft

fix conditional branch in fileread
author Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
date Wed, 11 Dec 2013 17:42:09 +0900
parents e08f6133f5d7
children ff4e06001518
line wrap: on
line source

#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/stat.h>
#include <iostream>
#include <vector>
#include <cstdlib>

#include "SchedTask.h"
#include "Print.h"
#include "Func.h"

/* これは必須 */
SchedDefineTask(Read);

static int
run(SchedTask *s, void *rbuf, void *wbuf)
{
    int *fd = (int *)s->get_input(rbuf,0);  ///ファイルディスクリプタの受取

    long task_number = (long)s->get_param(0);   //何番目のtaskか
    long division_size = (long)s->get_param(1);
    long read_size = (long)s->get_param(2);

    char text[(long)read_size];

    lseek(*fd, division_size* task_number,SEEK_SET);   //lseekでどこから読み込むのか指定
    read(*fd,text,(long)read_size);

    s->printf("[start task No. %d]\n",task_number);
    s->printf("%s\n",text);

    return 0;
}