kandi X-RAY | tlpi Summary
kandi X-RAY | tlpi Summary
对tlpi这本书的学习
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of tlpi
tlpi Key Features
tlpi Examples and Code Snippets
Community Discussions
Trending Discussions on tlpi
QUESTION
I am learning message queue from the examples from the book sample code: https://github.com/bradfa/tlpi-dist/blob/master/pmsg/pmsg_create.c
However, after compiling the code and run it with
...ANSWER
Answered 2021-May-12 at 05:57If you read the manpage for mq_open
(here's an online copy), it says:
EINVAL name doesn't follow the format in mq_overview(7).
mq_format(7) says that the name needs to begin with a slash (/
), which aaa
does not.
QUESTION
I'm currently reading the book "The Linux Programming Interface".
The example explaining pipes contains a piece of code which reads data from a pipe (inside the for loop, under the case 0
statement):
ANSWER
Answered 2020-May-12 at 21:18The pipe
function has this signature:
QUESTION
ANSWER
Answered 2020-Mar-19 at 02:47Here is a simplified example:
QUESTION
I am new to linux programming and learning it from The Linux Programming Interface by Michael Kerrisk.
I have to compile my first program that has dependencies.
Directory structure:
...ANSWER
Answered 2019-Jan-06 at 16:39The problem is with your second gcc
command, where you're using the -o
file to specify the output file where to store the resulting executable file, but passing it the name of the C source file seek_io.c
instead...
QUESTION
I tried to run an example program from a book called 'The Linux Programming Interface'. I copied all user-defined header files and functions from official website of book to my booklib location.
When I compiled the program, I took these errors. I need help about'Undefined reference to [functions_name]**.
code:
ANSWER
Answered 2017-Feb-28 at 19:33For the undefined references, someone asked a very similar answer here How to compile examples in the book "The Linux Programming Interface" by Michael Kerrisk
Then, if that does not work, I would suggest to try again by downloading the source file as specified at the TLPI web site and you can look into the makefile for your script, which is in the fileio/ subfolder and the Makefile.inc file.
QUESTION
I'm implementing a set of thread-safe functions that update and search an unbalanced binary tree with Pthreads (see The Linux Programming Interface: Exercise 30.2).
It's easy to implement a working tree that locks the entire body of functions like add
or delete
, but I believe it possible to implement an unbalanced binary (search) tree with a fine-grained locking strategy.
I've tried to 'port' a variety of hand-over-hand locking schemes from other data structures described in 'The Art of Multiprocessor Programming' but each requires that I transform the tree into a different primitive data structure (I'd like this to use an unbalanced binary tree as it's primitive data type, not just provide the same interface)
For clarity, here is the data structure used to represent the nodes of this tree.
...ANSWER
Answered 2017-Apr-18 at 21:43I'm implementing a set of thread-safe functions that update and search an unbalanced binary tree with Pthreads (see The Linux Programming Interface: Exercise 30.2).
It's easy to implement a 'functional' tree that simply locks the entire body of functions like add or delete, but I believe it possible to implement an unbalanced binary (search) tree with a locking strategy that allows for almost all the work to be parallelized by minimizing time spent in a critical section.
Yes and no. If two or more threads are to access the same shared data, and at least one of them modifies it, then both threads' accesses must be protected by some form of synchronization. Since you cannot, in general, predict in advance which nodes may be modified, all accesses need to be synchronized. On the other hand, the scope of the protected region can vary dynamically. Tree search, addition, and deletion algorithms for an unbalanced tree can narrow the scope of needed synchronization as they go, as in principle they only need to protect a subtree. Another thread could reasonably operate at the same time on a separate subtree.
Before you get excited about that, however, be aware that changing the synchronization scope is going to require a mutex lock and unlock (or vise versa, depending on your approach), and these are not cheap. You might find, in fact, that all the mutex locking and unlocking eats up most or all of the gains from parallelizing operations.
However, if you anticipate that searches will be the predominant operation on your tree, with additions and deletions being comparatively rare, then you could consider implementing a read/write lock. The idea there is that you permit any number of threads to search the tree at the same time, but a thread that wants to modify it must be granted exclusive access to the whole tree before it can do so.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install tlpi
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page