Information carriers. signals, signs, symbols.
Information carriers
Information is an intangible thing. This is information that is recorded (recorded) by one or another location (state) of a material medium, for example, the order of letters on the page or the amount of magnetization of the tape.
The information carrier can be any material object. And vice versa - any material object always carries some information (which, however, does not always have meaning for us). For example, a book as a combination of binding, paper sheets, and printing ink on them is a typical carrier of information.
Although any material object is a carrier of information, people use special objects as such, from which it is more convenient to read information.
The traditionally used storage medium is paper with images printed on it in one way or another.
Since in our time the main means of information processing is a computer, machine-readable media are mainly used to store information. Below is a complete list of known types of machine media with their quality characteristics.
Hard magnetic disk, LMD, HDD (hard disk, HD). It is used as the main stationary storage medium in computers. Large capacity, high access speed. Sometimes there are models with a removable disk that can be removed from the computer and hidden in a safe.
Flexible magnetic disk, floppy disk (FD) or floppy disk (diskette). The main removable media for personal computers. Small capacity, low access speed, but the cost is also low. The main advantage is transportability.
Laser compact disc (CD, CD-ROM). Large capacity, average access speed, but no ability to record information. The recording is made using special equipment.
Rewritable laser compact disc (CD-R, CD-RW). In some cases, only recording (without rewriting) is possible, in others there is also a limited number of data rewriting cycles. Same characteristics as a regular CD.
DVD. Similar to CD-ROM, but has a higher recording density (5-20 times). There are devices for both reading and writing (rewriting) DVDs.
Replaceable magnetic disk type ZIP or JAZZ. Similar to a floppy disk, but has a much larger capacity.
Magneto-optical or so-called floptic disk. High capacity removable media.
A magnetic tape cassette is a removable medium for a streamer, a device specifically designed for storing large amounts of data. Some computer models are adapted to record information on ordinary tape cassettes. The cassette has a large capacity and high read-write speed, but slow access to an arbitrary point on the tape.
Punch cards are almost never used nowadays.
Cassettes and ROM chips (read-only memory, ROM). They are characterized by the impossibility or difficulty of rewriting, small capacity, relatively high access speed, and also high resistance to external influences. Typically used in computers and other specialized electronic devices, such as game consoles, control modules of various devices, printers, etc.
Magnetic cards (strips). Small capacity, transportable, the ability to combine machine-readable and plain text information. Credit cards, passes, identification, etc.
There are a large number of specialized media used in various less common devices. For example, magnetic wire, hologram.
In addition, the information carrier is the computer's random access memory, RAM (RAM), but it is not suitable for long-term storage of information, since the data in it is not saved when the power is turned off.
Signals, signs, symbols.
Sign and signal are a form of information transmission. Signal transmission is a physical process that has informational value.
A symbol is a sign or signal filled with meaning. The signal can be continuous (analog) or discrete. An analog signal is a signal that continuously changes in amplitude and time. A signal is called discrete if it can take only a finite number of values. An analog signal can be represented in discrete form, for example, as a sequence of numbers.
The process of representing a quantity in the form of a sequential series of its individual (discrete) values is called discretization.
The signal cannot take on less than two different values. Signals transmitted in electrical form (the carrier is electromagnetic waves) have many advantages:
1) they do not require moving mechanical devices, which are slow and prone to breakdown;
2) the speed of transmission of electrical signals is approaching the maximum possible speed - the speed of light;
3) electrical signals are easy to process, compare and convert using electronic devices that are extremely fast.
Recently, signal transmission and processing systems have become increasingly widespread, in which analog signals arriving at the input are converted into digital form, the resulting digital signals are transmitted, stored, processed, and, if necessary, the signals are converted back from digital to analog form.
Articles to read:
- New discoveries from old experience - summing up
- Zero level of danger. preliminary analysis
IMPORTANT SIGNALS AND WARNINGS FROM YOUR GUARDIAN ANGEL
Similar articles:
- Storage media and technical means
For data storage, Personal computers have four hierarchical levels of memory: - microprocessor memory (MPM); — register cache memory; -...
- Modern media, methods of recording information on media
A floppy disk or floppy disk is a device for storing small amounts of information, which is a flexible plastic disk in a protective shell...
Practice working with signals
I want to capture a little experience working with signals in Linux. Below will be presented examples of the use of the most significant structures in this area. I’ll try to put everything on separate shelves so that it’s always easy to look and remember what to use and how. Important facts about signals:
- Signals in Linux play the role of a kind of means of inter-process communication (as well as inter-thread communication)
- Each process has a mask of signals (signals that it ignores receiving)
- Each thread, as well as a process, has its own signal mask
- When a signal is received (if it is not blocked), the process/thread is interrupted, control is passed to the signal handler function, and if this function does not terminate the process/thread, then control is transferred to the point at which the process/thread was interrupted
- You can set your own signal handler function, but only for a process. This handler will be called for each thread spawned from this process
I will not delve into the theory of signals, what from where, why and where. I am primarily interested in the mechanism of working with them. Therefore, the signals used will be SIGUSR1 and SIGUSR2; these are the only two signals given at the complete disposal of the user. I will also try to pay more attention to the inter-threaded interaction of signals. So, let's go. This function is called when a process (or thread) receives a non-blocking signal. The default handler terminates our process (thread). But we can ourselves define handlers for the signals that interest us. You should be very careful when writing a signal handler; it is not just a function executed by a callback; it interrupts the current thread of execution without any preparatory work, so global objects may be in an inconsistent state. The author does not undertake to provide a set of rules, since he himself does not know them, and urges you to follow the advice of Kobolog (I hope he doesn’t mind that I refer to it) and study at least this FAQ material. void hdl(int sig) { exit = true; } You can install a new signal handler using two functions sighandler_t signal(int signum, sighandler_t handler); Which takes the signal number, a pointer to the handler function (or SIG_IGN (ignore signal) or SIG_DFL (default handler)), and returns the old handler. The SIGKILL and SIGSTOP signals cannot be "intercepted" or ignored. The use of this function is highly discouraged because:
- the function does not block receiving other signals while the current handler is running, it will be interrupted and a new handler will start executing
- after the first receipt of a signal (for which we have installed our own handler), its handler will be reset to SIG_DFL
The function int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact); Which also accepts the signal number (except SIGKILL and SIGSTOP). The second argument is a new description for the signal, and the third argument returns the old value. The struct sigaction structure has the following fields of interest to us
- sa_handler - similar to sighandler_t in the signal function
- sa_mask — a mask of signals that will be blocked while our handler is running. + by default the received signal itself is blocked
- sa_flags - allows you to set additional actions when processing a signal, which you can read about here
Using this function looks quite simple: struct sigaction act;
memset(&act, 0, sizeof(act)); act.sa_handler = hdl; sigset_t set; sigemptyset(&set); sigaddset(&set, SIGUSR1); sigaddset(&set, SIGUSR2); act.sa_mask = set; sigaction(SIGUSR1, &act, 0); sigaction(SIGUSR2, &act, 0); Here we have installed our handler for the signals SIGUSR1 and SUGUSR2, and also specified that we need to block these same signals while the handler is executed. There is one not very convenient moment with the signal handler; it is installed on the entire process and all spawned threads at once. We do not have the ability to install its own signal handler for each thread. But it should be understood that when a signal is addressed to a process, the handler is called specifically for the main thread (representing the process). If the signal is addressed to a thread, then the handler is called from the context of that thread. See example 1. In order to block some signals for a process, you need to add them to the signal mask of this process. To do this, use the function int sigprocmask(int how, const sigset_t *set, sigset_t *oldset); We can add new signals to an existing signal mask (SIG_BLOCK), we can remove some signals from this mask (SIG_UNBLOCK), and we can also completely set our signal mask (SIG_SETMASK). To work with the signal mask inside a thread, use the function int pthread_sigmask(int how, const sigset_t *set, sigset_t *oset); which allows you to do everything the same, but for each thread separately. It is not possible to block SIGKILL or SIGSTOP signals using these functions. Attempts to do this will be ignored. This function allows you to pause the execution of a process (or thread) until the desired signal (or one of the signal masks) is received. The peculiarity of this function is that when a signal is received, the signal handler function will not be called. See example 2. In order to send a signal to a process, you can use two functions int kill(pid_t pid, int sig); int raise(int sig); The first one is clear. The second is needed in order to send a signal to itself, and is essentially equivalent to kill(getpid(), signal). The getpid() function returns the PID of the current process. In order to send a signal to a separate thread, the function int pthread_kill(pthread_t thread, int sig); Everything I described above does not answer the question “Why should I use signals.” Now I would like to give a real example of the use of signals and where you simply cannot do without them. Imagine that you want to read or write some data to some device, but this may lead to blocking. Well, for example, reading in the case of working with sockets. Or maybe recording in a pipe. You can put this in a separate thread so as not to block the main work. But what do you do when you need to terminate an application? How to gracefully abort a blocking IO operation? It would be possible to set a timeout, but this is not a very good solution. There are more convenient means for this: the pselect and ppoll functions. The difference between them is solely in usability; their behavior is the same. First of all, these functions are needed for multiplexing work with IO (select/poll). The prefix 'p' at the beginning of a function indicates that the function can be gracefully interrupted by a signal. So, let's formulate the requirement: It is necessary to develop an application that opens a socket (UDP for simplicity) and performs a read operation on the stream. This application must terminate correctly without delay when requested by the user. The thread function looks like this void* blocking_read(void* arg) { if(stop) { // we didn’t have time to start, but we were already covered?
std::cout << "Thread was aborted\n"; pthread_exit((void *)0); } // Block the SIGINT signal sigset_t set, orig; sigemptyset(&set); sigaddset(&set, SIGINT); sigemptyset(&orig); pthread_sigmask(SIG_BLOCK, &set, &orig); if(stop) { // while we were blocking the signal, it had already happened // return everything as it was and exit std::cout << “Thread was aborted\n”; pthread_sigmask(SIG_SETMASK, &orig, 0); pthread_exit((void *)0); } // We cannot be interrupted here with a SIGINT signal std::cout << “Start thread to blocking read\n”; // ... // create, configure the socket, prepare the structure for ppoll ppoll((struct pollfd*) &clients, 1, NULL, &orig); if(stop) { // received a signal to shut down std::cout << “Thread was aborted\n”; close(sockfd); pthread_sigmask(SIG_SETMASK, &orig, 0); // the SIGINT signal is still blocked here } // We were either reading data or some kind of error occurred. But we did not receive // a signal to complete the work and continue to work “according to plan” close(sockfd); pthread_exit((void *)0); } stop
is a global boolean flag that is set to
true
by our handler, which tells the thread to terminate. The operating logic is as follows:
- We check that while the thread has started, they have not yet decided to end it
- blocking the final signal
- we check that while they blocked us, they did not want to terminate us
- call ppoll passing as the last parameter the signal mask for which the signal is expected
- after exiting ppoll, we check that we did not exit due to a completion signal
This is what the main function looks like int main() { ... struct sigaction act;
memset(&act, 0, sizeof(act)); act.sa_handler = hdl; sigemptyset(&act.sa_mask); sigaddset(&act.sa_mask, SIGINT); sigaction(SIGINT, &act, 0); ... pthread_kill(th1, SIGINT); ... } We install our handler for SIGINT, and when we need to terminate the child thread, we send this signal to it. For a complete listing, see example 3. In my opinion, the disadvantage of this method is that in the case of several threads, we can only terminate them all at once. It is not possible to install a different signal handler for each thread. Thus, it is not possible to implement full-fledged inter-threaded interaction through signals. The Linux way does not provide for this.
PS.
I posted the source codes on the PasteBin service (I don’t give a link, otherwise they will consider it an advertisement). P.P.S. Please forgive me for the abundance of errors. Language is my weak side. Thanks to everyone who helped fix them. This article does not pretend to be a complete (and in-depth) description of working with signals and is aimed primarily at those who have not previously encountered the concept of “signal”. For a deeper understanding of how signals work, the author encourages you to turn to more competent sources and read the constructive criticism in the comments.
Appendix 2: Sound Signal Table
To Art. 34
| |||
TABLE OF SOUND SIGNALS |
The procedure for clearing bells on surface ships of rank 1 and 2
Signal name | Bugle call | Signal with siren, bell, bell | |
character | Transfer procedure | ||
1 | 2 | 3 | 4 |
“Combat alert” | № 1 | One continuous signal - on ships and support vessels call ………. - on submarines howler —————- | Transmitted once |
"A drill" | No. 13 and 1 | Three short and one continuous beep … ___________ | Transmitted once |
“Emergency Alarm” | Can't play | 25−30 short beeps …………. | Transmitted once. On submarines, simultaneously with the “Emergency Alarm” , the running lights and emergency signal buoy are turned on and flashing |
"Chemical Alert" | Can't play | Four short and one long beep …. _________ | Repeats three times with an interval of 2 seconds. |
“Radiation Hazard” | Can't play | One short and two long beeps: . ___ ___. ___ ___ howler - on submarines by bell - on surface ships | Repeats three times with an interval of 2 seconds. |
“Big gathering” | № 2 | One short and one long beep . ___ . ___. ___ | Repeated 12-15 times without gaps |
“Small gathering” | № 3 | Three short beeps … … | Repeats twice with an interval of 1 second |
“Avral” | Can't play | One short and one long beep . __. __. __ | Repeated 10-15 times without gaps |
“Prepare the ship for battle and voyage” | Can't play | two short beeps …….. | Repeats three times with an interval of 2 seconds. |
“Urgent Dive” | Can't play | At least ten short signals with a howler …………… | Transmitted once |
“Open (Close) the ventilation valve of the end groups of the Central City Hospital” | Can't play | One short roar signal . | Transmitted once |
“Open (Close) the ventilation valve of the middle group of the Central City Hospital” | Can't play | Two short beeps .. | Transmitted once |
“Open (Close) emergency latches of the Central City Hospital” | Can't play | Three short beeps … | Transmitted once |
“Open (Close) the kingstons of the end groups of the CGB” | Can't play | One short beep . | Transmitted once |
“Open (Close) kingstons of the middle groups of the Central City Hospital” | Two short beeps … | Transmitted once | |
“The stern (large stern) horizontal rudders are jammed” | One continuous ringing signal ————— | Sound duration is 25-30 seconds. | |
“The speakerphone is out of order” | Four long signals with a bell and a bell at the same time __ __ __ __ __ __ __ __ | Transmitted once | |
“Checking alarms and emergency lighting” | Four long signals with a bell and a bellower alternately __ __ __ __ __ __ __ __ | Transmitted once | |
(Listen up everyone) After transmitting the signal by voice (via broadcast), the required order is transmitted.” | № 4 | Three short beeps … … | Repeats twice with an interval of 2 seconds. |
Checking calls during inspection and testing of mechanisms | Three short beeps … | Transmitted once | |
“Alarm clear” (or end of announced action) | № 21 | Three long beeps ____ ____ ____ | Transmitted once |
Start, break and continuation of classes and work | Can't play | One long beep ____________________ | Transmitted once |
PROCEDURE FOR REMOVING FLACKS ON SURFACE SHIPS OF RANK 1 AND 2
08.00 — 8 bells are struck (four * double strikes on the ship’s bell)
08.30 - beat off 1 bell (one hit)
09.00 - beat 2 bells (one double blow)
09.30 - 3 bells are struck (one double strike and one strike) and so on until 12.00.
12.00 - they beat the bell ** (three times the ship’s bell is struck three times).
From the next half hour, i.e. from 12.30, a new count of bells begins until 16.00 ,
from 16.00 to 20.00 and from 20.00 to 23.00 , i.e. until lights out.
At 23.00 6 bells are struck.
Ship commanders, by their orders, determine which members of the duty and watch services should answer the bells.
* — A double strike is made on both edges of the ship’s bell
** — “Rynda” is a special battle indicating noon.
Note:
1. On surface ships and vessels that do not have a device for issuing a signal with a changing tone, the “Combat Alert” is given by a bell (loud bell).
2. Alarms, except for combat and training ones, announced for training purposes, unlike actual alarm signals, are preceded by a bell or bellower - the “Listen all” (No. 10 - once) and a broadcast voice - the word “Training” .
3. Duration of sounds:
Continuous or - 25−30 sec.
Long lasting – 2 sec.
Short - 0.5 - 0.7 sec.
The duration of the intervals between the sounds of the signals is 0.2 - 0.5 seconds 4. In the event of a malfunction of the bell circuit, the emergency alarm signal can be given by the ship's bell (a series of frequent strikes).
- Home /
- Documentation /
- Navy Ship's Charter /
- Appendix 2: Sound Signal Table