Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
|
12-07-2022, 08:28 AM
|
#16
|
LQ Guru
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,316
|
The point of this assignment is obviously to demonstrate an understanding of these specific concepts. Not to do production-ready engineering. Hence its contrived requirements.
In real life, you would put the queue on a server designed specifically for them, such as ZeroMQ, RabbitMQ, Kafka or Redis.
Last edited by dugan; 12-07-2022 at 10:46 AM.
|
|
|
12-07-2022, 07:17 PM
|
#17
|
LQ Guru
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,820
|
Yes, it is clear that this is "an exercise," and I would also consider it to be a well-designed one. I hope that the student in question will embrace it.
I would also encourage the student to work directly and closely with the obviously-skilled instructor who created it and assigned it.
Last edited by sundialsvcs; 12-07-2022 at 07:18 PM.
|
|
|
12-15-2022, 01:56 PM
|
#18
|
LQ Guru
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,820
|
In my experience, the only way to arrange "the reading of a file by multiple processes or threads" is to create a single process or thread which is ultimately responsible for managing the file. Everyone else must issue "requests" to read-or-write specified segments of it, and await the reply. The responsible process now receives these requests one at a time. They are now serialized.
This approach removes all of the uncertainty that is inherent in operating-system level serialization mechanisms, and instead reduces it to a very simple "client/server paradigm." The "server" process or thread now receives all of the requests, one at a time (very fast). It has an extremely simple thing to do, and a clear algorithm for doing it: if there is "contention," this one actor can reliably resolve it. The microseconds required are inconsequential. It is a robust strategy.
Every modern programming language provides the "queue" classes and objects needed to accomplish this – if not a ready-made solution to the entire ("very well-known ...") problem itself. "Do Not Do A Thing Already Done.™"
Last edited by sundialsvcs; 12-15-2022 at 02:05 PM.
|
|
|
All times are GMT -5. The time now is 10:21 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|