44a0 Synchronous - Telecomix Crypto Munitions Bureau

Synchronous

From Telecomix Crypto Munitions Bureau

Jump to: navigation, search

Something that has "immediate" response.

Immediate is a "very short period of time", relative to the context.

Examples:

  • Calling a function that immeadiately returns the boolean TRUE.
  • Kicking a table and feeling the pain "immediately after".

Compare with asynchronous.

[edit] Actually..

The above is wrong. Its just there to make it easier to think about it.

It means that a system has a common agreement of in which order events occured.

A single-threaded non-networked program is synchronous (like a simple program written in ordinary C). The order of events is obvious (and often does not need to be tracked), since nothing else than the single process itself can change its own variables.

If "a system" is a "network of computers with multiples processes at each node", it would need to have some sort of fancy network protocol for keeping track of events occurring.

A synchronous system has a notion of cause and effect.

[edit] Simple definition: System, state, event

  • System = ANYTHING that has a state and reacts to events.
    • Examples: A rock, a single-core CPU, a process in a computer, a section of code in a program that has its own variables, a distributed networked file system
  • State = A set of variables that the system can change.
    • Examples: The alignment of atoms in the rock, the contents of all processor registers and all RAM in your entire computer, a variable stored in a program, a memory region shared between two processes, a State variable in an erlang gen_server process.
  • Event = Something that happens (that is relevant to the state of the system).
    • Examples: Someone making an attempt at turning the rock upside down, a client enters input, a process crash and risk losing its state

[edit] Atomic operations

An atomic operation is something that happens within a period of time during which nothing else happens. It change the state of the system at one single instant.

Atomic operations needs the entire system to have an common agreement upon which events occured, and in which order they occured. Otherwise the atomicity of the operations can not be guaranteed. In larger systems that has difficulties to maintain a common agreement of in which order events occured, this is sometimes solved with rollback functions that undo the operation if it turned out that something went wrong (databases often do this).

Examples:

  • One of the CPU-cores in your computer LOCKs the data and address bus, so that no other CPU may enter a value at a specified location in the computers RAM. It then modifies the RAM and unlocks the busses.
  • A corporate database issues a command to change the account balance at your bank account. The operation needs to be atomic, otherwise you could hack the system by sending a 2nd request to modify the value of your bank account -- before the first request is complete.
  • All individual single-instruction machine codes executing inside a single-core CPU that neither supports out-of-order-execution nor hyperthreading (that is: oldskool industrial processors.)

[edit] Limits to synchronous systems

  • Security can be a problem if the system that keeps track of in which order events occurred is compromised. If all nodes in a network is trusted to help keeping track of the passing of time, no single computer can be pwned/owned by a malicious user for the system to maintain its reliability. (Bitcoin is a synchronous network of nodes that all help keeping track of in which order transactions are being made, without trusting any single node. PDF here.)
  • Complexity. The more complex a system is, the more complex will the protocol for managing the common state become.
  • "Bandwidth" is a problem if a state-change requires a lot of subsystems to exchange messages before they can agree upon a new state.
  • The speed of light sets the upper limit to how quickly a system can agree upon a common state. If two CPUs are located 30 centimeters from each others, it will take at least one nanosecond (or perhaps three if a reply and an acknowledge of the reply are sent) to change their common state.

[edit] See also

Personal tools
0