📜 ⬆️ ⬇️

Automaton-style programs - translation difficulties



The fifth lecture of the course “Network Programming in UNIX” from SkyDNS specialists and Aydeko company is already waiting for its listeners.

Alexander Patrakov explains how to translate a regular network program into a program based on a state machine.
')
What is a state machine, you will learn under habrakatom.

This lecture is necessary to listen to understand the following. Open the mystery, the topic of the next lecture is the select () function, which in most cases cannot be used without an automaton. The developer of the course, Alexander Patrakov, explained that both topics are quite complex, so it’s not necessary to talk about select () and the state machine in one lecture.

A finite automaton is defined by mathematicians as a set of states, a set of input symbols, and a transition table. Programmers do not use this expression in a strict mathematical sense, but as a name for the method of organizing a program, in which it is broken into pieces, each of which ponders the input data and decides which piece will be next.

Alexander emphasizes that automaton state transition handlers should not contain network input-output operations, except for one call to the rev () or send () function. It must be called at the very beginning. This means that the loop for reading from the socket, which was discussed in the last lecture, should not be used in an automatic program. The machine gun can cope with this task itself, as Alexander Patrakov and Mark Korenberg tell about, starting from the 34th minute of the video.

In this lecture, students were given the task of remaking an astrological server to use a finite state machine.

“This topic, I believe, is one of the most difficult in the whole course, and I must admit that most of the students coped with it,” said Alexander Patrakov. - I will note one more important point: the use of a finite state machine without select () is an artificial task. In real programs, using a state machine without select () is usually impractical and only confuses the code. ”

And you can not get confused? We are sure that you can, because in the video there were again slides that will help you learn the material.

By the way, Alexander Patrakov will gladly explain what remained unclear after watching the lecture. Leave your questions in the comments. Also tell us what this lecture was interesting for and what it would cost to add. Your opinion is important to us!



Previous lectures:
1. A course for those who are not afraid of UNIX and C
2. Each client in the process
3. Implement the protocol or how astrologers work
4. How to read to the end

Source: https://habr.com/ru/post/143886/


All Articles