Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
function calling using pointers
--GNAT 4.9.3 with Ada.Text_IO; use Ada.Text_IO; with Ada.Integer_Text_IO;use Ada.Integer_Text_IO; procedure advanced_schedular is type adv_schd is access function return Integer; function TaskA return Integer is C,A,B: Integer; begin A:=3; B:=2; C:=A+B; New_Line; Put(C); return 0; end TaskA; function TaskB return Integer is C,A,B: Integer; begin A:=3; B:=2; C:=A*B; New_Line; Put(C); return 0; end TaskB; function TaskC return Integer is C,A,B: Integer; begin A:=3; B:=2; C:=A-B; New_Line; Put(C); return 0; end TaskC; function TaskD return Integer is A: array(1..25) of Integer; I: Integer; temp: Integer; begin A:=(1,4,3,5,6,7,25,6,1,2,3,4,2,1,6,7,8,9,2,1,3,4,5,6,98); temp:=A(1); for I in 1..24 loop if (A(I+1)>A(I)) and then (A(I+1)>temp) then temp:= A(I+1); end if; end loop; New_Line; Put(temp); return 0; end TaskD; function TaskE return Integer is S: string (1..25); I: Integer; begin S:="<Sensor:ONN><Sensor:ONN> "; New_Line; Put_Line(S(1..12)); return 0; end TaskE; type adv_sch is record state:Integer; ptr: adv_schd; end record; tcb: array(1..5) of adv_sch; C:Integer; begin tcb(1).state:=1; tcb(2).state:=2; tcb(3).state:=3; tcb(4).state:=4; tcb(5).state:=5; tcb(1).ptr:=taskA'Access; tcb(2).ptr:=taskB'Access; tcb(3).ptr:=taskC'Access; tcb(4).ptr:=taskD'Access; tcb(5).ptr:=taskE'Access; Put(tcb(1).state); Put(tcb(2).state); Put(tcb(3).state); Put(tcb(4).state); Put(tcb(5).state); --Put("helloo"); end advanced_schedular;
run
|
edit
|
history
|
help
0
suma_enteros_ppal.adb
Queue (Using Tasking)
ada rocks!
1d array as 4d with easy reshaping
division_emtera_p.adb
macro-like function
Ada nested lexical scope
plop
susuma_dos_enteros.adb
Dynamic Dispatching