You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: chapters/c.asciidoc
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -397,7 +397,7 @@ either beam instructions or BIFs, depending on their complexity.
397
397
Library functions are basic Erlang functions such as 'lists:length/1' that are part of the Erlang language. They could be implemented as BEAM instructions,
398
398
BIFS, or in Erlang.
399
399
400
-
BIFs are efficient as they are writen in C and optimized for performance within the BEAM.
400
+
BIFs are efficient as they are written in C and optimized for performance within the BEAM.
401
401
The disadvantages with BIFs are that long-running BIFs can block BEAM schedulers, affecting system responsiveness. They have limited extensibility as they are fixed within the runtime system.
402
402
403
403
Most Erlang users will never need to write a BIF, but it is good to know what they are and how they work. Also if you are writing an EEP (Erlang Enhancement Proposal) you might need to write a BIF to implement the new functionality.
/* Check the arguemnt and return an error if it is not a positive integer.
452
+
/* Check the argument and return an error if it is not a positive integer.
453
453
When defining a BIF with BIF_ALIST_X the arguments are named
454
454
BIF_ARG_1, BIF_ARG_2 etc.
455
455
To signal ann error use BIF_ERROR(BIF_P, BADARG);
@@ -629,7 +629,7 @@ tuple and call 'math_factorial_trap_1'.
629
629
Now when we come back from a yield we might already have a bignum so we
630
630
restructure the code a bit to handle this case.
631
631
632
-
We check our iterator and every 1000 interations we save the state and yield. We also save the state and yield when we have a bignum.
632
+
We check our iterator and every 1000 iterations we save the state and yield. We also save the state and yield when we have a bignum.
633
633
634
634
```c
635
635
static Export math_factorial_trap_export;
@@ -719,7 +719,7 @@ bignum_loop:
719
719
// Increment i so we don't get stuck in a loop. with i % 1000 == 0.
720
720
// Save state: {(i+1), i!, n} and yield.
721
721
722
-
// Store the tuple with the sate on the heap
722
+
// Store the tuple with the state on the heap
723
723
big_size = BIG_SIZE(big_val(big_factorial));
724
724
hp = HAlloc(BIF_P, 4 + big_size + 1);
725
725
big_hp = hp + 4;
@@ -790,7 +790,7 @@ It was a calm night, one of those rare occasions where everything in the system
790
790
791
791
In the aftermath, the investigation revealed a peculiar sequence of events. The BEAM schedulers, designed to gracefully balance work and sleep, had been too eager to shut down when the workload diminished. Only a single scheduler remained active, handling the entirety of the system's operations.
792
792
793
-
As fate would have it, this lone scheduler stumbled upon a task: converting a 4MB term into a binary for logging purposes. This seemingly routine operation invoked the term_to_binary function—a built-in function (BIF). Instead of breaking its workload into manageable chunks, it perfomed all the work until done and then reported it had used only 20 reductions.
793
+
As fate would have it, this lone scheduler stumbled upon a task: converting a 4MB term into a binary for logging purposes. This seemingly routine operation invoked the term_to_binary function—a built-in function (BIF). Instead of breaking its workload into manageable chunks, it performed all the work until done and then reported it had used only 20 reductions.
794
794
795
795
This non-yielding nature proved to be a fatal flaw. The single scheduler became entirely consumed, unable to handle other tasks or respond to the system's needs. Erlang's HEART mechanism, ever vigilant, detected the unresponsiveness and concluded that the node was beyond saving. With grim efficiency, it killed the node.
Copy file name to clipboardExpand all lines: chapters/debugging.asciidoc
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@
4
4
=== Introduction
5
5
This chapter goes into the various methods for finding and fixing bugs without disrupting the services in progress. We will explore testing techniques, tools, and frameworks that aid in testing and debugging your code. We'll also shed light on some common bug sources, such as deadlocks, message overflow, and memory issues, providing guidance on identifying and resolving these problems.
6
6
7
-
Debugging is the process of identifying and eliminating errors, or "bugs," from software. While Erlang offers step-by-step debugging tools like the link:http://erlang.org/doc/apps/debugger/debugger_chapter.html[_Debugger_], the most effective debugging methods often rely on Erlang's tracing facilities. These facilities will be thoroughly discussed in Chapter xref:CH-Tracing[]. In this chapter We will touch on system level tracing witth dtrace and systemtap.
7
+
Debugging is the process of identifying and eliminating errors, or "bugs," from software. While Erlang offers step-by-step debugging tools like the link:http://erlang.org/doc/apps/debugger/debugger_chapter.html[_Debugger_], the most effective debugging methods often rely on Erlang's tracing facilities. These facilities will be thoroughly discussed in Chapter xref:CH-Tracing[]. In this chapter We will touch on system level tracing with dtrace and systemtap.
8
8
9
9
This chapter also explores the concept of "Crash Dumps," which are human-readable text files generated by the Erlang Runtime System when an unrecoverable error occurs, such as running out of memory or reaching an emulator limit. Crash Dumps are invaluable for post-mortem analysis of Erlang nodes, and you will learn how to interpret and understand them.
10
10
@@ -601,7 +601,7 @@ This dump suggests that the system crashed due to a memory allocation failure (`
601
601
1. Slogan
602
602
Indicates the reason for the crash. Common slogans include:
603
603
- `eheap_alloc: Cannot allocate X bytes of memory` (Memory exhaustion)
604
-
- `Init terminating in do_boot ()` (Pobably an erro in the boot script)
604
+
- `Init terminating in do_boot ()` (Pobably an error in the boot script)
605
605
- `Could not start kernel pid` (Probably a bad argument in config)
Copy file name to clipboardExpand all lines: chapters/io.asciidoc
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -270,7 +270,7 @@ PortSettings)`.
270
270
A file descriptor port is opened with `{fd, In, Out}` as the
271
271
`PortName`. This class of ports is used by some internal ERTS servers
272
272
like the old shell. They are considered to not be very efficient and
273
-
hence seldom used. Also the filedescriptors are non negative intgers
273
+
hence seldom used. Also the filedescriptors are non negative integers
274
274
representing open file descriptors in the OS. The file descriptor can
275
275
not be an erlang I/O server.
276
276
@@ -389,7 +389,7 @@ By scheduling signals to/from the port asynchronously, Erlang ensures that proce
389
389
390
390
Now this means that the erlang send operation is not always asynchronous. If the port is busy the send operation will block until the port is not busy anymore. This is a problem if you have a lot of processes sending data to the same port. The solution is to use a port server that can handle the backpressure and make sure that the send operation is always asynchronous.
391
391
392
-
Let's do an example based on the offical port driver example:
392
+
Let's do an example based on the official port driver example:
0 commit comments