OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [tags/] [nog_patch_38/] [or1ksim/] [testbench/] [uos/] [task.c] - Diff between revs 1401 and 1765

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 1401 Rev 1765
/* This file is part of test microkernel for OpenRISC 1000. */
/* This file is part of test microkernel for OpenRISC 1000. */
/* (C) 2000 Damjan Lampret, lampret@opencores.org */
/* (C) 2000 Damjan Lampret, lampret@opencores.org */
 
 
#include "support.h"
#include "support.h"
#include "uos.h"
#include "uos.h"
#include "ipc.h"
#include "ipc.h"
#include "int.h"
#include "int.h"
 
 
extern struct tcb tasks[MAX_TASKS+1];
extern struct tcb tasks[MAX_TASKS+1];
 
 
int task(int id)
int task(int id)
{
{
        int rc;
        int rc;
        struct _msg {
        struct _msg {
                char            id;
                char            id;
                unsigned long   count;
                unsigned long   count;
        } msg;
        } msg;
 
 
        printf("Task %d started\n", id);
        printf("Task %d started\n", id);
 
 
        if(id == 1) {
        if(id == 1) {
                msg.id = 1;
                msg.id = 1;
                msg.count = 0;
                msg.count = 0;
                uos_msgsnd(2, (char *)&msg, sizeof(msg));
                uos_msgsnd(2, (char *)&msg, sizeof(msg));
        }
        }
 
 
        for(;;) {
        for(;;) {
                rc = uos_msgrcv(0, (char *)&msg, sizeof(msg));
                rc = uos_msgrcv(0, (char *)&msg, sizeof(msg));
 
 
                if(rc != 0) {
                if(rc != 0) {
                        printf("Task %d: Waiting for massage\n", id);
                        printf("Task %d: Waiting for massage\n", id);
                } else {
                } else {
                        printf("Task %d: Got massage from task %d: 0x%.8x. Sending message to task %d: 0x%.8x \n", id, msg.id, (int)msg.count, (id == 3 ? 1 : (id + 1)), (int)(msg.count  + 1));
                        printf("Task %d: Got massage from task %d: 0x%.8x. Sending message to task %d: 0x%.8x \n", id, msg.id, (int)msg.count, (id == 3 ? 1 : (id + 1)), (int)(msg.count  + 1));
                        msg.id = id;
                        msg.id = id;
 
 
                        if((id == 1) && (msg.count > 15)) {
                        if((id == 1) && (msg.count > 15)) {
                                report(msg.count + 0xdeadde9c);
                                report(msg.count + 0xdeadde9c);
                                exit(0);
                                exit(0);
                        }
                        }
 
 
                        msg.count += 1;
                        msg.count += 1;
                        uos_msgsnd((id == 3 ? 1 : (id + 1)), (char *)&msg, sizeof(msg));
                        uos_msgsnd((id == 3 ? 1 : (id + 1)), (char *)&msg, sizeof(msg));
                }
                }
        }
        }
}
}
 
 
/* Called by kernel_init to collect all tasks entries. */
/* Called by kernel_init to collect all tasks entries. */
void tasks_entries()
void tasks_entries()
{
{
        tasks[1].regs.pc = (unsigned long)task;
        tasks[1].regs.pc = (unsigned long)task;
        tasks[2].regs.pc = (unsigned long)task;
        tasks[2].regs.pc = (unsigned long)task;
        tasks[3].regs.pc = (unsigned long)task;
        tasks[3].regs.pc = (unsigned long)task;
}
}
 
 
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.