text
stringlengths
0
234
if Random_Num > Error_Rate then
return x + 10;
else
raise Count_Failed;
end if;
end Unreliable_Slow_Add;
task type Transaction_Worker (Initial : Integer; Manager : access Transaction_Manager);
task body Transaction_Worker is
Num : Integer := Initial;
Prev : Integer := Num;
Round_Num : Integer := 0;
begin
Put_Line ("Worker" & Integer'Image(Initial) & " started");
loop
Put_Line ("Worker" & Integer'Image(Initial) & " started round" & Integer'Image(Round_Num));
Round_Num := Round_Num + 1;
---------------------------------------
-- PART 2: Do the transaction work here
---------------------------------------
begin
Num := Unreliable_Slow_Add( Num );
Manager.Finished;
exception
when Count_Failed =>
begin
Put_Line( " Worker" & Integer'Image( Initial ) & " aborting" );
Manager.Signal_Abort;
Manager.Finished;
Function Definition: procedure Convert_Card_Identification_Data_Register
Function Body: (W0, W1, W2, W3 : UInt32;
Res : out Card_Identification_Data_Register);
-- Convert the R2 reply to CID
procedure Convert_Card_Specific_Data_Register
(W0, W1, W2, W3 : UInt32;
Card_Type : Supported_SD_Memory_Cards;
CSD : out Card_Specific_Data_Register);
-- Convert the R2 reply to CSD
procedure Convert_SDCard_Configuration_Register
(W0, W1 : UInt32;
SCR : out SDCard_Configuration_Register);
-- Convert W0 (MSB) / W1 (LSB) to SCR.
function Compute_Card_Capacity
(CSD : Card_Specific_Data_Register;
Card_Type : Supported_SD_Memory_Cards) return UInt64;
-- Compute the card capacity (in bytes) from the CSD
function Compute_Card_Block_Size
(CSD : Card_Specific_Data_Register;
Card_Type : Supported_SD_Memory_Cards) return UInt32;
-- Compute the card block size (in bytes) from the CSD.
function Get_Transfer_Rate
(CSD : Card_Specific_Data_Register) return Natural;
-- Compute transfer rate from CSD
function Swap32 (Val : UInt32) return UInt32 with Inline_Always;
function BE32_To_Host (Val : UInt32) return UInt32 with Inline_Always;
-- Swap bytes in a word
------------
-- Swap32 --
------------
function Swap32 (Val : UInt32) return UInt32 is
begin
return Shift_Left (Val and 16#00_00_00_ff#, 24)
or Shift_Left (Val and 16#00_00_ff_00#, 8)
or Shift_Right (Val and 16#00_ff_00_00#, 8)
or Shift_Right (Val and 16#ff_00_00_00#, 24);
end Swap32;
------------------
-- BE32_To_Host --
------------------
function BE32_To_Host (Val : UInt32) return UInt32 is
use System;
begin
if Default_Bit_Order = Low_Order_First then
return Swap32 (Val);
else
return Val;
end if;
end BE32_To_Host;
---------------------------------
-- Card_Identification_Process --
---------------------------------