Skip to content
Snippets Groups Projects
Commit e21968fe authored by aht2nguy's avatar aht2nguy
Browse files

modified perf test, still not working

parent fd71971b
No related branches found
No related tags found
No related merge requests found
#ifndef K2P_H
#define K2P_H
int Sender();
int Receiver();
int PerfTest();
#endif
#ifndef K2PERFTEST_H
#define K2PERFTEST_H
int Sender();
int Receiver();
int PerfTest();
void Sender();
void Receiver();
void firstUserTask();
#endif
......@@ -50,9 +50,11 @@ RPSClient2 with TaskID 4 chose Paper
>>>>>>> We have a Draw. <<<<<<
```
#### Instructions to Play
At the prompt, please enter your choice for RPSClient1 and RPSClient2.
The result of the play is marked with `>>>>>> and <<<<<<`
The game continues until one player quits.
At the prompt, please enter your choice for both RPSClient1 and RPSClient2.
Entering randomly will just loop the prompt till it gets one of the selected charaters.
The result of a game is marked with `>>>>>> result <<<<<<` for better visuals :)
The game continues until one player quits.
#### Reasoning
We decided to give the NameServer of 5 the lowest priority and the RPSServer of 3, 1 higher than both the Client1 of 4, and Client2 of 4. The reasoning is as follows:
......
......@@ -48,6 +48,9 @@ k3.s: k3.c
k2.s: k2.c
$(XCC) -S $(CFLAGS) k2.c
k2Perf.s: k2Perf.c
$(XCC) -S $(CFLAGS) k2Perf.c
kernel.s: kernel.c
$(XCC) -S $(CFLAGS) kernel.c
......@@ -119,6 +122,9 @@ k3.o: k3.s
k2.o: k2.s
$(AS) $(ASFLAGS) -o k2.o k2.s
k2Perf.o: k2Perf.s
$(AS) $(ASFLAGS) -o k2Perf.o k2Perf.s
kernel.o: kernel.s
$(AS) $(ASFLAGS) -o kernel.o kernel.s
......@@ -189,6 +195,9 @@ k3.a: k3.o
k2.a: k2.o
$(AR) $(ARFLAGS) $@ k2.o
k2Perf.a: k2Perf.o
$(AR) $(ARFLAGS) $@ k2Perf.o
kernel.a: kernel.o
$(AR) $(ARFLAGS) $@ kernel.o
......@@ -226,7 +235,7 @@ tools.a: tools.o
$(AR) $(ARFLAGS) $@ tools.o
install: buffer.a bwio.a clock-task.a clockserver-api.a context-switch.a event-itr.a hash-table.a idle-task.a ipc.a kernel.a k3.a k2.a min-heap.a nameserver.a notifier.a priority-q.a rps.a scheduler.a syscall.a syscall-handler.a td.a timer.a tools.a
install: buffer.a bwio.a clock-task.a clockserver-api.a context-switch.a event-itr.a hash-table.a idle-task.a ipc.a kernel.a k3.a k2.a k2Perf.a min-heap.a nameserver.a notifier.a priority-q.a rps.a scheduler.a syscall.a syscall-handler.a td.a timer.a tools.a
mv buffer.a libbuffer.a
mv bwio.a libbwio.a
mv clock-task.a libclktsk.a
......@@ -238,6 +247,7 @@ install: buffer.a bwio.a clock-task.a clockserver-api.a context-switch.a event-i
mv ipc.a libipc.a
mv k3.a libk3.a
mv k2.a libk2.a
mv k2Perf.a libk2p.a
mv kernel.a libkernel.a
mv min-heap.a libmh.a
mv nameserver.a libns.a
......
#include <bwio.h>
#include <types.h>
#include <k2PerfTest.h>
#include <k2Perf.h>
#include <timer.h>
#include <syscall.h>
int Sender() {
return 0;
/*
void Sender() {
int MyID = MyTid();
bwprintf(COM2,"Sender: %d runs\n\r",MyID);
Buffer** AllSendQ = GetAllSendQ();
Buffer SendQ;
int QStorage[MAX_NUM_TD];
SendQ.Storage = (void *)QStorage;
SendQ.Size = MAX_NUM_TD;
SendQ.Length = 0;
SendQ.Head = 0;
SendQ.Tail = 0;
AllSendQ[MyIndex] = &SendQ;
bwprintf(COM2,"Sender ID: %d runs\n\r",MyID);
int ReceiverTID, i, StartTime, EndTime, Res;
int Sum = 0, Average;
char* SendMsg = "water water water loo loo loo, water water water loo loo loo, water water water loo loo loo cs452 cs452";
int Sum = 0;
float Average;
char SendMsg[] = "water water water loo loo loo, ";
bwprintf(COM2, "size of SendMsg %d\n\r", sizeof(SendMsg));
ReceiverTID = 1;
char ReplyMsg[32]; // 4 bytes
//char ReplyMsg[256]; // 64 bytes
//Clock* c;
//ClockInit(c);
//ReceiverTID = WhoIs("Rcvr");
bwprintf(COM2, "size of ReplyMsg %d\n\r", sizeof(ReplyMsg));
bwprintf(COM2,"before loop\n\r");
for (i = 0; i < 100; ++i) {
//ClockUpdate(c);
//StartTime = c->ClockCount;
Res = Send(ReceiverTID, (char*)SendMsg, 32, ReplyMsg, 32);
bwprintf(COM2, "Sender: about to Send\n\r");
Res = Send(ReceiverTID, (void*)SendMsg, 32, (void*)ReplyMsg, 32);
if (Res != 32) {
bwprintf(COM2, "here\n\r");
bwprintf(COM2, "Send has Errors\n\r");
return Res;
}
bwprintf(COM2,"here2222222222\n\r");
//ClockUpdate(c);
//EndTime = c->ClockCount;
//Sum += (EndTime - StartTime);
}
//Average = Sum/100;
Average = Sum/(float)100;
bwprintf(COM2, "Send Time: \n\r", Average);
Exit();
*/
}
int Receiver() {
return 0;
/* int MyID = MyTid();
bwprintf(COM2,"Receiver:%d runs\n\r", MyID);
void Receiver() {
Buffer** AllSendQ = GetAllSendQ();
Buffer SendQ;
int QStorage[MAX_NUM_TD];
SendQ.Storage = (void *)QStorage;
SendQ.Size = MAX_NUM_TD;
SendQ.Length = 0;
SendQ.Head = 0;
SendQ.Tail = 0;
AllSendQ[MyIndex] = &SendQ;
int MyID = MyTid();
bwprintf(COM2,"Receiver TaskID:%d \n\r", MyID);
int SenderTID, i, StartTime, EndTime, Res;
int Sum = 0, Average;
int Sum = 0;
float Average;
char ReceiveMsg[32];
char ReplyMsg[32]; // 4 bytes
Clock* c;
SenderTID = 2;
bwprintf(COM2,"Receiver: Guess1\n\r");
ClockInit(c);
// Res = RegisterAS("Rcvr");
//Reply(SenderTID, ReplyMsg, sizeof(ReplyMsg));
StartTime = 0;
bwprintf(COM2,"Receiver: Before Loop\n\r");
for (i = 0; i < 100; i++) {
ClockUpdate(c);
Res = Receive(SenderTID, (char*)ReceiveMsg, 32);
Res = Receive(SenderTID, (void*)ReceiveMsg, 32);
if (Res < 0) {
bwprintf(COM2, "Receive has Errors.\n\r");
return Res;
}
ClockUpdate(c);
EndTime = c->ClockCount;
Reply(SenderTID, (char*)ReplyMsg, Res);
Reply(SenderTID, (void*)ReplyMsg, Res);
Sum += (EndTime-StartTime);
}
Average = Sum / 100;
Average = Sum / (float)100;
bwprintf(COM2, "Receive Time: %d\n\r", Average);
Exit();
*/
}
int PerfTest() {
return 0;
/*
int SenderTID, ReceiverTID, NSTID, SendFirst = 1;
AP Args1, Args5;
char* SendMsg, ReplyMsg;
void firstUserTask() {
int SenderTID, ReceiverTID;
AP Args3, Args5;
// Send before Receive
Args5.arg0 = (void *) 5;
Args5.arg1 = (void *) (&Receiver);
//Args1.arg0 = (void *) 1;
//Args1.arg1 = (void *) (&Receiver);
Args3.arg0 = (void *) 3;
Args3.arg1 = (void*) (&Sender);
//NSTID = Create(&Args5);
// Receive before Send
// Args5.arg0 = (void *) 5;
// Args5.arg1 = (void *) (&Sender);
// Args3.arg0 = (void *) 3;
// Args3.arg1 = (void*) (&Receiver);
ReceiverTID = Create(&Args5);
//Args5.arg1 = (void*)(&Sender);
SenderTID = Create(&Args1);
bwprintf(COM2, "receiver taskid %d\n\r", ReceiverTID);
SenderTID = Create(&Args3);
bwprintf(COM2, "Sender taskid %d\n\r", SenderTID);
bwprintf(COM2,"\n\r");
bwprintf(COM2,"PerfTest exiting...\n\r");
//Send(ReceiverTID, (void*)SendMsg, sizeof(SendMsg), (void*)Reply, sizeof(ReplyMsg));
Exit();
*/
}
......@@ -155,12 +155,12 @@ int Player(int ID){
Result = Send(ServerTID, &SendMsg, sizeof(RPSMsg), &ReplyMsg, sizeof(RPSMsg));
bwprintf(COM2, "%s with ID %d signed up successfully.\n\r", Name, MyTID);
// bwprintf(COM2, "%s with ID %d signed up successfully.\n\r", Name, MyTID);
if (Result != sizeof(ReplyMsg)) {
bwprintf(COM2, "Sign Up Request to Server did not go through.");
return Result;
}
bwprintf(COM2, "===============Let's Start a Game !!! ===================\n\r");
//bwprintf(COM2, "===============Let's Start a Game !!! ===================\n\r");
FOREVER {
bwprintf(COM2, "Please enter r/R for Rock, p/P for Paper, s/S for Scissors, or q/Q to Quit\n\r");
while (Input = bwgetc(COM2)) {
......
......@@ -29,7 +29,7 @@ main.o: main.s
main.elf: main.o
$(LD) $(LDFLAGS) -o $@ main.o -lk2 -lk3 -lsysh -lipc -lrps -lclktsk -lidt -lns -lbuffer -lcsvapi -lntf -lsys -lei -lsche -lcs -lpq -lkernel -ltd -lht -lmh -ltools -ltimer -lbwio -lgcc
$(LD) $(LDFLAGS) -o $@ main.o -lk2 -lk3 -lk2p -lsysh -lipc -lrps -lclktsk -lidt -lns -lbuffer -lcsvapi -lntf -lsys -lei -lsche -lcs -lpq -lkernel -ltd -lht -lmh -ltools -ltimer -lbwio -lgcc
perfmain.elf: perfmain.o
$(LD) $(LDFLAGS) -o $@ perfmain.o -lk2p -lsysh -lipc -lbuffer -lsys -lsche -lcs -lpq -lkernel -ltd -lht -ltools -ltimer -lbwio -lgcc
......
......@@ -2,7 +2,8 @@
#include <bwio.h>
#include <event-itr.h>
//#include <k3.h>
#include <k2.h>
// #include <k2.h>
#include <k2Perf.h>
#include <kernel.h>
#include <priority-q.h>
#include <syscall.h>
......@@ -33,7 +34,8 @@ int main()
//Buffer* SendQs[MAX_NUM_TD];
InitSwi();
kernelInit(&Colonel);
TD* FUT = CreateTask(&Colonel, 1, (void *) (&firstUserTaskChildren));
// TD* FUT = CreateTask(&Colonel, 1, (void *) (&firstUserTaskChildren)); // for Kernel2 RPS
TD* FUT = CreateTask(&Colonel, 1, (void *) (&firstUserTask)); // for Perf
pushToScheduler(&Colonel, FUT);
TD* Task;
......
File added
File added
.file "main.c"
.text
.align 2
.global Init_BWIO
.type Init_BWIO, %function
Init_BWIO:
@ args = 0, pretend = 0, frame = 0
@ frame_needed = 1, uses_anonymous_args = 0
mov ip, sp
stmfd sp!, {fp, ip, lr, pc}
sub fp, ip, #4
mov r0, #1
mov r1, #0
bl bwsetfifo(PLT)
mov r0, #1
ldr r1, .L3
bl bwsetspeed(PLT)
ldmfd sp, {fp, sp, pc}
.L4:
.align 2
.L3:
.word 115200
.size Init_BWIO, .-Init_BWIO
.align 2
.global main
.type main, %function
main:
@ args = 0, pretend = 0, frame = 3356
@ frame_needed = 1, uses_anonymous_args = 0
mov ip, sp
stmfd sp!, {sl, fp, ip, lr, pc}
sub fp, ip, #4
sub sp, sp, #3344
sub sp, sp, #12
ldr sl, .L14
.L13:
add sl, pc, sl
bl Init_BWIO(PLT)
sub r3, fp, #3360
sub r3, r3, #12
str r3, [fp, #-56]
bl InitSwi(PLT)
sub r3, fp, #3120
sub r3, r3, #12
mov r0, r3
bl kernelInit(PLT)
sub r3, fp, #3120
sub r3, r3, #12
mov r0, r3
mov r1, #1
ldr r3, .L14+4
ldr r3, [sl, r3]
mov r2, r3
bl CreateTask(PLT)
mov r3, r0
str r3, [fp, #-28]
sub r3, fp, #3120
sub r3, r3, #12
mov r0, r3
ldr r1, [fp, #-28]
bl pushToScheduler(PLT)
mov r3, #0
str r3, [fp, #-20]
mov r0, #51
bl EnableInterrupt(PLT)
.L6:
ldr r3, [fp, #-3132]
cmp r3, #0
bne .L7
mov r3, #0
str r3, [fp, #-20]
sub r3, fp, #3120
sub r3, r3, #12
mov r0, r3
bl getNextTaskScheduler(PLT)
mov r3, r0
str r3, [fp, #-24]
b .L9
.L7:
ldr r3, [fp, #-3132]
str r3, [fp, #-24]
ldr r3, [fp, #-24]
ldr r3, [r3, #12]
str r3, [fp, #-20]
.L9:
ldr r3, [fp, #-24]
cmp r3, #0
beq .L10
sub r3, fp, #3120
sub r3, r3, #12
mov r0, r3
ldr r1, [fp, #-24]
bl Activate(PLT)
mov r3, r0
str r3, [fp, #-32]
sub r3, fp, #3120
sub r3, r3, #12
mov r0, r3
ldr r1, [fp, #-32]
bl Handle(PLT)
b .L6
.L10:
mov r3, #0
mov r0, r3
sub sp, fp, #16
ldmfd sp, {sl, fp, sp, pc}
.L15:
.align 2
.L14:
.word _GLOBAL_OFFSET_TABLE_-(.L13+8)
.word firstUserTask(GOT)
.size main, .-main
.ident "GCC: (GNU) 4.0.2"
#include <buffer.h>
#include <bwio.h>
#include <event-itr.h>
//#include <k3.h>
#include <k2.h>
#include <kernel.h>
#include <priority-q.h>
#include <syscall.h>
#include <syscall-handler.h>
#include <scheduler.h>
#include <td.h>
#include <timer.h>
#include <types.h>
void Init_BWIO(){
bwsetfifo(COM2,OFF);
bwsetspeed(COM2,115200);
}
int main()
{
Init_BWIO();
KernelStruct Colonel;
int req;
Buffer* SendQs[MAX_NUM_TD];
Colonel.AllSendQ = SendQs;
//EventAwaitTask WaitEvents[NUM_EVENTS];
//InitWaitEventTable(WaitEvents);
//Colonel.WaitTable = WaitEvents;
//Buffer* SendQs[MAX_NUM_TD];
InitSwi();
kernelInit(&Colonel);
TD* FUT = CreateTask(&Colonel, 1, (void *) (&firstUserTaskChildren));
pushToScheduler(&Colonel, FUT);
TD* Task;
int ReturnValue = 0;
EnableInterrupt(51);
//bwprintf(COM2,"Main AllSendQ Address is %d\n\r",SendQs);
FOREVER {
if(Colonel.Active == NULL){
// bwprintf(COM2, "===================new====================\n\r");
ReturnValue = 0;
Task = getNextTaskScheduler(&Colonel);
}
else{
// bwprintf(COM2,"========================old=======================\n\r");
Task = Colonel.Active;
ReturnValue = Task->RetVal;
}
if(Task == NULL) break;
// bwprintf(COM2,"main: Task%d, Priority: %d\n\r", Task->TaskID,Task->TaskPriority);
req = Activate(&Colonel,Task);
Handle(&Colonel, req);
}
return 0;
}
#include <buffer.h>
#include <bwio.h>
#include <event-itr.h>
//#include <k3.h>
//#include <k2.h>
#include <k2Perf.h>
#include <kernel.h>
#include <priority-q.h>
#include <syscall.h>
#include <syscall-handler.h>
#include <scheduler.h>
#include <td.h>
#include <timer.h>
#include <types.h>
void Init_BWIO(){
bwsetfifo(COM2,OFF);
bwsetspeed(COM2,115200);
}
int main()
{
Init_BWIO();
KernelStruct Colonel;
int req;
Buffer* SendQs[MAX_NUM_TD];
Colonel.AllSendQ = SendQs;
//EventAwaitTask WaitEvents[NUM_EVENTS];
//InitWaitEventTable(WaitEvents);
//Colonel.WaitTable = WaitEvents;
//Buffer* SendQs[MAX_NUM_TD];
InitSwi();
kernelInit(&Colonel);
TD* FUT = CreateTask(&Colonel, 1, (void *) (&firstUserTaskChildren));
pushToScheduler(&Colonel, FUT);
TD* Task;
int ReturnValue = 0;
EnableInterrupt(51);
//bwprintf(COM2,"Main AllSendQ Address is %d\n\r",SendQs);
FOREVER {
if(Colonel.Active == NULL){
// bwprintf(COM2, "===================new====================\n\r");
ReturnValue = 0;
Task = getNextTaskScheduler(&Colonel);
}
else{
// bwprintf(COM2,"========================old=======================\n\r");
Task = Colonel.Active;
ReturnValue = Task->RetVal;
}
if(Task == NULL) break;
// bwprintf(COM2,"main: Task%d, Priority: %d\n\r", Task->TaskID,Task->TaskPriority);
req = Activate(&Colonel,Task);
Handle(&Colonel, req);
}
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment