Ping-pong Scheme
   HOME

TheInfoList



OR:

Algorithms said to employ a ping-pong scheme exist in different fields of
software engineering Software engineering is a branch of both computer science and engineering focused on designing, developing, testing, and maintaining Application software, software applications. It involves applying engineering design process, engineering principl ...
. They are characterized by an alternation between two entities. In the examples described below, these entities are communication partners, network paths or file blocks.


Databases

In most
database management systems In computing, a database is an organized collection of data or a type of data store based on the use of a database management system (DBMS), the software that interacts with end users, applications, and the database itself to capture and ana ...
durable Durability is the ability of a physical product to remain functional, without requiring excessive maintenance or repair, when faced with the challenges of normal operation over its design lifetime. There are several measures of durability in us ...
database transaction A database transaction symbolizes a unit of work, performed within a database management system (or similar system) against a database, that is treated in a coherent and reliable way independent of other transactions. A transaction generally rep ...
s are supported through a
log file In computing, logging is the act of keeping a log of events that occur in a computer system, such as problems, errors or broad information on current operations. These events may occur in the operating system or in other software. A message o ...
. However, multiple writes to the same page of that file can produce a slim chance of data loss. Assuming for simplicity that the log file is organized in pages whose size matches the
block Block or blocked may refer to: Arts, entertainment and media Broadcasting * Block programming, the result of a programming strategy in broadcasting * W242BX, a radio station licensed to Greenville, South Carolina, United States known as ''96.3 ...
size of its underlying medium, the following problem can occur: If the very last page of the log file is only partially filled with data and has to be written to permanent storage in this state, the very same page will have to be overwritten during the next write operation. If a crash happens during that later write operation, previously stored log data may be lost. The ping-pong scheme described in ''Transaction Processing'' eliminates this problem by alternately writing the contents of said (logical) last page to two different physical pages inside the log file (the actual last page ''i'' and its empty successor ''i+1''). Once said logical log page is no longer the last page (i.e. it is completely filled with log data), it is written one last time to the regular physical position (''i'') inside the log file. This scheme requires the usage of time stamps for each page in order to distinguish the most recent version of the logical last page one from its predecessor.


Networking


Internet

A functionality which lets a computer A find out whether a computer B is reachable and responding is built into the
Internet Control Message Protocol The Internet Control Message Protocol (ICMP) is a supporting protocol in the Internet protocol suite. It is used by network devices, including routers, to send error messages and operational information indicating success or failure when com ...
(ICMP). Through an "Echo Request" Computer A asks B to send back an "Echo Reply". These two messages are also sometimes called "
ping Ping may refer to: Arts and entertainment Fictional characters * Ping, a domesticated Chinese duck in the illustrated book '' The Story about Ping'', first published in 1933 * Ping, a minor character in ''Seinfeld'', an NBC sitcom * Pingg, a ...
" and "pong" for historical purposes.


Routing

In
routing Routing is the process of selecting a path for traffic in a Network theory, network or between or across multiple networks. Broadly, routing is performed in many types of networks, including circuit-switched networks, such as the public switched ...
, a Ping-Pong scheme is a simple algorithm for distributing data packets across two paths. If you had two paths A and B, then the algorithm would randomly start with one of the paths and then switch back and forth between the two.{{Cite book , last1=Swaminathan , first1=K. , last2=Lakshminarayanan , first2=G. , last3=Ko , first3=Seok-Bum , title=2012 International Symposium on Electronic System Design (ISED) , chapter=High Speed Generic Network Interface for Network on Chip Using Ping Pong Buffers , date=December 2012 , chapter-url=https://ieeexplore.ieee.org/document/6526556 , pages=72–76 , doi=10.1109/ISED.2012.11, isbn=978-1-4673-4704-4 , s2cid=23635498 If you were to get the next path from a function call, it would look like this in
Python Python may refer to: Snakes * Pythonidae, a family of nonvenomous snakes found in Africa, Asia, and Australia ** ''Python'' (genus), a genus of Pythonidae found in Africa and Asia * Python (mythology), a mythical serpent Computing * Python (prog ...
: def get_next_path(): """ This function is a generator that infinitely yields the strings "A" and "B" in an alternating sequence. Yields: str: The next string in the sequence, either "A" or "B". """ while True: yield "A" yield "B"


References

Algorithms Articles with example Python (programming language) code