A method for providing security on controllers, the method comprising: detecting computer-readable code running on a controller, the computer-readable code being stored in a memory in a plurality of code portions, each code portion comprising one or more instructions to be performed by the controller; responsive to detecting the computer-readable code running on the controller, identifying a current code portion of the computer-readable code that is running; characterized in that the method further comprises: accessing an in-memory graph that models an operational flow of the computer-readable code, wherein the in-memory graph comprises a plurality of nodes, each of the nodes corresponding to one of the code portions and each of the nodes having a risk value for the associated code portion that is a measure of security risk for the associated code portion; identifying the risk value for the current code portion; selecting , from a plurality of available flow control integrity, IMV, schemes, an IMV scheme based on the identified risk value; applying , to the code portion as the code portion is running on the controller, the selected IMV scheme; and responsive to a determination that the computer-readable code running on the controller fails the selected IMV scheme, taking a corrective action. detecting computer-readable code running on a controller, the computer-readable code being stored in a memory in a plurality of code portions, each code portion comprising one or more instructions to be performed by the controller; responsive to detecting the computer-readable code running on the controller, identifying a current code portion of the computer-readable code that is running; characterized in that the method further comprises: accessing an in-memory graph that models an operational flow of the computer-readable code, wherein the in-memory graph comprises a plurality of nodes, each of the nodes corresponding to one of the code portions and each of the nodes having a risk value for the associated code portion that is a measure of security risk for the associated code portion; identifying the risk value for the current code portion; selecting , from a plurality of available flow control integrity, IMV, schemes, an IMV scheme based on the identified risk value; applying , to the code portion as the code portion is running on the controller, the selected IMV scheme; and responsive to a determination that the computer-readable code running on the controller fails the selected IMV scheme, taking a corrective action. accessing an in-memory graph that models an operational flow of the computer-readable code, wherein the in-memory graph comprises a plurality of nodes, each of the nodes corresponding to one of the code portions and each of the nodes having a risk value for the associated code portion that is a measure of security risk for the associated code portion; identifying the risk value for the current code portion; selecting , from a plurality of available flow control integrity, IMV, schemes, an IMV scheme based on the identified risk value; applying , to the code portion as the code portion is running on the controller, the selected IMV scheme; and responsive to a determination that the computer-readable code running on the controller fails the selected IMV scheme, taking a corrective action. <EOS>