pragma Task_Dispatching_Policy (FIFO_Within_Priorities); with MaRTE_OS; with Text_IO; use Text_IO; with Ada.Unchecked_Conversion; with System; with Basic_Integer_Types; use Basic_Integer_Types; -- with Processor_Registers; with Non_Local_Jump; with System.Machine_Code; use System.Machine_Code; procedure Non_Local_Jump_Test is pragma Linker_Options("eat_20.o"); procedure Eat_20; pragma Import (C, Eat_20, "eat_20"); pragma Priority (10); -- package PR renames Processor_Registers; package PR renames Non_Local_Jump; Cont : Integer := 0; pragma Volatile (Cont); TCB : System.Address := System.Null_Address; pragma Volatile (TCB); function Pthread_Self return System.Address; pragma Import (C, Pthread_Self, "pthread_self"); Jmp_Buff : aliased PR.Jmp_Context; pragma Volatile (Jmp_Buff); procedure Por_Fastidiar2 (C : Integer) is begin loop Put_Line (Integer'Image (C)); Eat_20; --for I in 1 .. 20_000_000 loop -- null; --end loop; end loop; end Por_Fastidiar2; procedure Por_Fastidiar1 (C : Integer) is begin Por_Fastidiar2 (C); end Por_Fastidiar1; -- tarea q se cambia su dirección de retorno task Saltarina is pragma Priority (5); end Saltarina; task body Saltarina is begin Put_Line ("hola2"); TCB := Pthread_Self; loop PR.Save_Context(Jmp_Buff'Access); -- Asm ("int $3", No_Output_Operands, No_Input_Operands, "", True); if PR.After_Jump (Jmp_Buff'Access) = 1 then Put_Line ("---After Jump---"); else Por_Fastidiar1 (Cont); Put_Line ("---Not After Jump---"); end if; Cont := Cont + 1; Put_Line(" Cont:" & Integer'Image (Cont)); end loop; exception when E:others => Put_Line ("Exception in Saltarina"); end Saltarina; begin loop delay 2.0; exit when Cont >= 5; Put_Line ("Antes de cambiar retorno 3"); PR.Restore_Context (TCB, Jmp_Buff'Access); Put_Line ("Desp de cambiar retorno 3"); --delay 1000000.0; end loop; Put_Line (Integer'Image (Jmp_Buff'Size/8)); end Non_Local_Jump_Test;