Пример #1
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    this->var = 0;

    //Start a thread and execute doProcessing()
    QThread* thread = new QThread();
    workingThread* worker = new workingThread( &(this->var) );

    worker->moveToThread(thread);
    //connect(worker, SIGNAL(error(QString)), this, SLOT(errorString(QString)));
    connect(thread, SIGNAL(started()), worker, SLOT(doProcessing()));
    connect(worker, SIGNAL(finished()), this, SLOT(onThreadQuit()));
    connect(worker, SIGNAL(finished()), worker, SLOT(deleteLater()));
    connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
    thread->start();


    for(double d = 0;d < 10e6; d++);
    qDebug("Main: set var = 1");
    this->var = 1;
    for(double d = 0;d < 10e6; d++);
    this->var = 2;
    qDebug("Main: set var = 2");
    for(double d = 0;d < 10e6; d++);
    this->var = 3;
    qDebug("Main: set var = 3");

    qDebug("Main finished ...");
}
void detection::GraspPointDetector::detect(const CloudPtr &input_object)
{
  clock_t beginCallback = clock();

  // If no cloud or no new images since last time, do nothing.
  if (input_object->size() == 0) return;

  world_obj_ = input_object->makeShared();
  pub_cluster_.publish(world_obj_);

  // Check if computation succeeded
  if (doProcessing())
    ROS_INFO("[%g ms] Detection Success", durationMillis(beginCallback));
  else
    ROS_ERROR("[%g ms] Detection Failed", durationMillis(beginCallback));
}
Пример #3
0
// A process dispatcher program
// @par: int                number of arguments
// @par: pointer pointer    process list file
// @ret: int
int main(int argc, char **argv) {
    if (argc != 2) {
        // Print directions if the file is not supplied and exit
        printf("You must supply a file to the program:\n"
                "$ hostd filename.txt\n");
        exit(0);
    }

    initSystem();

    char *filename = argv[1];
    readFile(filename, dispatcher);
    if (VERBOSE) printf("Done processing %s!\n", filename);

    // Set CPU start time to 0
    int time = 0;

    // Flag when a real time process is added to the real time queue
    int rtUpdated;

    // The system is running
    /*while (time < runtime) {*/
    while (time < 20) {
        printf("===============================================================================================================================\n");
        printf("Time (Quantum): %d\n", time);
        printf("===============================================================================================================================\n");

        rtUpdated = updateDispatcher(time);

        if (VERBOSEMEMMAP) {
            printf("Current %d MByte memory map (each line is 64 Mbyte).\n", host.memSpaceMax);
            int memUnit;
            for(memUnit = 0; memUnit < MAX_MEMSPACE; memUnit++) {
                if (host.memSpace[memUnit] != 0) {
                    printf("%d ", host.memSpace[memUnit]);
                } else {
                    if (memUnit < MAX_RTMEMSPACE) {
                        printf(". ");
                    } else {
                        printf("_ ");
                    }
                }

                if ((memUnit + 1) % 64 == 0) {
                    printf("\n");
                }
            }
            printf("\n");
        }

        if (VERBOSEQ) {
            printf("REAL TIME QUEUE:  ");
            printQueue(realTimeQueue);

            printf("PRIORITY 1 QUEUE: ");
            printQueue(p1Queue);

            printf("PRIORITY 2 QUEUE: ");
            printQueue(p2Queue);

            printf("PRIORITY 3 QUEUE: ");
            printQueue(p3Queue);

            //TODO
            //print info about system resources and per process resources?
        }

        doProcessing(time, rtUpdated);

        time++;

        sleep(1);
        printf("\n");
    }

    printf("===============================================================================================================================\n");
    printf("Time (Quantum): %d, program terminating\n", time);
    printf("===============================================================================================================================\n");

    closeSystem();

    return 0;
}
Пример #4
0
void socketServer(char** params)
{
    int sockfd, newsockfd, portno, clilen;
    char buffer[256];
    struct sockaddr_in serv_addr, cli_addr;
    int  n, pid;

    /* First call to socket() function */
    sockfd = socket(AF_INET, SOCK_STREAM, 0);

    if (sockfd < 0)
    {
        perror("ERROR opening socket");
        exit(1);
    }

    /* Initialize socket structure */
    bzero((char *) &serv_addr, sizeof(serv_addr));
    //portno = 5001;
    portno = atoi(params[2]);

    serv_addr.sin_family = AF_INET;
    serv_addr.sin_addr.s_addr = INADDR_ANY;
    serv_addr.sin_port = htons(portno);

    /* Now bind the host address using bind() call.*/
    if (bind(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0)
    {
        perror("ERROR on binding");
        exit(1);
    }

    /* Now start listening for the clients, here
    * process will go in sleep mode and will wait
    * for the incoming connection
    */

    listen(sockfd,5);
    clilen = sizeof(cli_addr);

    while (1)
    {
        newsockfd = accept(sockfd, (struct sockaddr *) &cli_addr, &clilen);
        if (newsockfd < 0)
        {
            perror("ERROR on accept");
            exit(1);
        }

        /* Create child process */
        pid = fork();
        if (pid < 0)
        {
            perror("ERROR on fork");
            exit(1);
        }

        if (pid == 0)
        {
            /* This is the client process */
            close(sockfd);
            doProcessing(newsockfd);
            exit(0);
        }
        else
        {
            close(newsockfd);
        }
    } /* end of while */
}
Пример #5
0
int main()
{
	Widget w(20);
	doProcessing(w);
	return 0;
}