From: Mart Lubbers Date: Thu, 11 May 2017 11:36:43 +0000 (+0200) Subject: update memory consumption on task acknowledgement X-Git-Url: https://git.martlubbers.net/?a=commitdiff_plain;h=8e31b107ced5cae9230623a22d11ca37f391e74a;p=mTask.git update memory consumption on task acknowledgement --- diff --git a/Devices/mTaskDevice.dcl b/Devices/mTaskDevice.dcl index 618020b..d75256b 100644 --- a/Devices/mTaskDevice.dcl +++ b/Devices/mTaskDevice.dcl @@ -45,6 +45,6 @@ sendMessages :: [MTaskMSGSend] -> (MTaskDevice -> Task Channels) withDevices :: MTaskDevice (MTaskDevice -> MTaskDevice) -> Task () deviceTaskDelete :: MTaskDevice MTaskTask -> Task () -deviceTaskAcked :: MTaskDevice Int -> Task () +deviceTaskAcked :: MTaskDevice Int Int -> Task () deviceTaskDeleteAcked :: MTaskDevice Int -> Task () deviceAddSpec :: MTaskDevice MTaskDeviceSpec -> Task () diff --git a/Devices/mTaskDevice.icl b/Devices/mTaskDevice.icl index ad848d2..c8bee61 100644 --- a/Devices/mTaskDevice.icl +++ b/Devices/mTaskDevice.icl @@ -112,9 +112,11 @@ sendMessages msgs = upd (\(r,s,ss)->(r,msgs++s,ss)) o channels withDevices :: MTaskDevice (MTaskDevice -> MTaskDevice) -> Task () withDevices a trans = upd (map \b->if (b == a) (trans b) b) deviceStore @! () -deviceTaskAcked :: MTaskDevice Int -> Task () -deviceTaskAcked dev i - = withDevices dev (\d->{d&deviceTasks=ackFirst d.deviceTasks}) +deviceTaskAcked :: MTaskDevice Int Int -> Task () +deviceTaskAcked dev i mem + = withDevices dev (\d->{d + &deviceTasks=ackFirst d.deviceTasks + ,deviceSpec=Just {fromJust d.deviceSpec & bytesMemory=mem}}) where ackFirst :: [MTaskTask] -> [MTaskTask] ackFirst [] = [] diff --git a/client/task.c b/client/task.c index 9206a13..4ed23ee 100644 --- a/client/task.c +++ b/client/task.c @@ -50,9 +50,11 @@ void task_register(void) debug("Received a task of length %d", t->tasklength); t->lastrun = 0L; t->taskid = taskid++; + t->value = 0; write_byte('t'); write16(t->taskid); + write16(mem_free()); write_byte('\n'); debug("free memory: %lu\n", mem_free()); } diff --git a/client/task.h b/client/task.h index 2e483f2..bcd0783 100644 --- a/client/task.h +++ b/client/task.h @@ -14,6 +14,7 @@ struct task { uint8_t taskid; struct task *next; uint8_t *bc; + int value; }; bool is_interrupt_task(struct task* t); diff --git a/mTaskInterpret.dcl b/mTaskInterpret.dcl index 922b445..578d335 100644 --- a/mTaskInterpret.dcl +++ b/mTaskInterpret.dcl @@ -11,7 +11,7 @@ from GenPrint import generic gPrint from Generics.gCons import class gCons, generic conses, generic consName, generic consIndex, generic consNum :: MTaskMSGRecv - = MTTaskAck Int + = MTTaskAck Int Int | MTTaskDelAck Int | MTSDSAck Int | MTSDSDelAck Int diff --git a/mTaskInterpret.icl b/mTaskInterpret.icl index 8b489d8..27d4c43 100644 --- a/mTaskInterpret.icl +++ b/mTaskInterpret.icl @@ -53,7 +53,7 @@ decode x | not (trace_tn ("decoding: " +++ toString (toJSON x))) = undef | size x == 0 = MTEmpty = case x.[0] of - 't' = MTTaskAck $ fromByteCode x + 't' = MTTaskAck (fromByteCode x) (fromByteCode (x % (2, size x))) 'd' = MTTaskDelAck $ fromByteCode x 'm' = MTMessage x 's' = MTSDSAck $ fromByteCode x @@ -81,7 +81,8 @@ instance toString MTaskMSGSend where +++ " value " +++ safePrint v instance toString MTaskMSGRecv where - toString (MTTaskAck i) = "Task added with id: " +++ toString i + toString (MTTaskAck i mem) = "Task added with id: " +++ toString i + +++ " free memory: " +++ toString mem toString (MTTaskDelAck i) = "Task deleted with id: " +++ toString i toString (MTSDSAck i) = "SDS added with id: " +++ toString i toString (MTSDSDelAck i) = "SDS deleted with id: " +++ toString i diff --git a/miTask.icl b/miTask.icl index b0378c1..0e7a631 100644 --- a/miTask.icl +++ b/miTask.icl @@ -67,7 +67,7 @@ mTaskManager = startupDevices >>| anyTask // MTSDSAck i = traceValue (toString m) @! () // MTSDSDelAck i = traceValue (toString m) @! () MTPub i val = updateShare i val - MTTaskAck i = deviceTaskAcked device i + MTTaskAck i mem = deviceTaskAcked device i mem MTTaskDelAck i = deviceTaskDeleteAcked device i @! () MTDevSpec s = deviceAddSpec device s @! () _ = treturn ()