r/computerscience 10h ago

Does Wait-Free require Garbage-Free?

7 Upvotes

Wait-Free means that every thread must finish its operation in a bounded number of steps. That bound can be arbitrarily high, e.g. dependent on the number of concurrent threads, but it must be finite. And the finite bound must be there in all cases, i.e. it is not sufficient to say that an algorithm "usually" finishes "reasonably" (i.e. "usually" does not spend unbounded times helping other threads).

The first practical implementation of a multiple-enqueuer multiple-dequeuer Wait-Free Queue was proposed by Kogan and Petrank. The key idea is that threads help each other, but in a way that newer threads (more precisely: newer operations) are obliged to help older threads (operations), but not vice versa. Also, plainly said: If a thread cannot make progress with its own operation, it becomes older and older, up to the point when all other threads are obliged to help (only) him, thus ensuring the Wait-Free progress.

The issue of the Kogan and Petrank Queue is, however, that it is based on a linked list of nodes. This means that its operations constantly produce memory churn, also require memory allocation and memory clean-up. From Java - where the clean-up is done by a Garbage Collector - I borrow the term "Garbage".

Now, the problem is that Wait-Free memory allocation is problematic. Imagine, e.g., when the process needs a new memory page from the operating system. Can this ever be made Wait-Free?

Memory reclamation in a concurrent setup is a complex topic on top of that. One of the key questions here is: When can a memory block be freed safely, i.e. how do we "know" that no thread has a pointer to it anymore?

Given this, it appears that one needs a structure without memory churn (i.e. Garbage-Free) to be able to make it Wait-Free. At least practically.

I would be grateful for a discussion on this.

Additional info:

Here I have combined the Multi-Array Queue (which is Garbage-Free by nature (except of the extension operations, of course)) with the Kogan and Petrank idea, with the aim to obtain a Queue that is Wait-Free unconditionally.

The GitHub repo also contains a visual simulator to illustrate the principle:

https://github.com/MultiArrayQueue/WaitFreeMultiArrayQueue


r/computerscience 17h ago

General How does Lean work?

22 Upvotes

In light of the recent counterproof of the Jacobian Conjecture, I've been looking more into proofs, and I can't wrap my head around how Lean works. In my mind, proofs always require a certain amount of intuition and judgement behind them, so I'm confused how a deterministic programming language can infer from said proofs?


r/computerscience 9h ago

Why does the CPU’s size matter?

0 Upvotes

Why does it matter if it’s a 16-bit cpu, a 32-bit cpu, or 64-bit? For example, what can a 64-bit cpu do that a 32-bit one can’t? Or otherwise, and can you tell the difference when you casually use a computer?


r/computerscience 1d ago

Discussion Is the standard Word RAM model becoming too disconnected from modern algorithmic theory?

24 Upvotes

I was re-reading Frigo et al.'s paper on cache-oblivious algorithms recently, and now i'm thinking about how heavily introductory algorithms courses rely on the uniform-cost Word RAM model. We teach time complexity based on unit-cost memory access, but in memory-hierarchy model theory (like the External Memory / I/O model by Aggarwal and Vitter), asymptotic bounds depend heavily on block size $B$ and cache capacity $M$.

Feels like there's a gap in how we teach foundational complexity versus cache-aware algorithmic analysis. Obviously the RAM model's simplicity is ideal for proving basic asymptotic bounds, but at what point does it obscure important theoretical properties of data structures on hierarchical memory?

Would like to how other departments go about introducing cache-oblivious models alongside standard Big-O analysis in upper-level theory courses.


r/computerscience 16h ago

Is it possible to have pixels run on 1 PC per pixel?

0 Upvotes

What I mean is 1080p has 2,073,600 pixels so what if every single pixel is run by a individual PC like 2,073,600 PCs?

I was thinking this might be a way to create a super-computer that can put out a insane amount of framerate.


r/computerscience 1d ago

General what’s the connection between union-find and the inverse ackermann function?

14 Upvotes

while doing competitive coding problems i frequently come across solutions that use union find (DSU) and list the big O of their solution as O(\alpha(n)) where \alpha(n) is the inverse ackermann function. after some surface level research, i have come away with many more questions than answers. So why is the DSU related to the ackermann function, and is there an intuitive or natural connection between the two ?


r/computerscience 1d ago

Advice how would you introduce comsci to a person who knows nothing about computers and programming and such ?

0 Upvotes

title says it all


r/computerscience 2d ago

The Message Arrived. Did the Operation Succeed? On End-to-End Arguments in System Design.

Thumbnail mohamed.computer
0 Upvotes

r/computerscience 2d ago

Article Using Verification to Eliminate Bugs in nftables

Thumbnail basis.ai
2 Upvotes

r/computerscience 4d ago

It feels fundamentally wrong to use packages without understanding concepts under the hood

41 Upvotes

I have recently started coding and people are recommending tools for development such as vite, nodemon, jwt, boiler plate server code

It feels pointless just using them with a basic understanding and without no deep conceptual understanding. Is this the right or wrong approach? How would you know going too deep into a rabbit hole and becoming overkill


r/computerscience 4d ago

Help how could the positive output of a gate, be used for a negative input for another gate? (im completely new)

Post image
30 Upvotes

im not into computer stuff, but this has been bugging me since i watched some free courses.


r/computerscience 5d ago

Why is a Word (a 16-bit unsigned integer) called a "Word"?

124 Upvotes

r/computerscience 5d ago

Visual, interactive explanations of classic data structures (ring buffer, priority queue, bloom filter, LSM tree...)

Post image
69 Upvotes

Made this while re-learning some structures I hadn't touched since undergrad — each chapter has an animation synced to the explanation as you scroll, plus where the structure actually shows up in real systems (kfifo, RocksDB, Dijkstra's algorithm, etc). ledger.khushal.net — feedback on what to cover next welcome.


r/computerscience 4d ago

What does "Design an algorithm before starting to create your program" mean?

9 Upvotes

r/computerscience 5d ago

Discussion How many truly concurrent operations occur on a home computer?

0 Upvotes

About 15 years ago I discovered that despite the number of cores a CPU had, the system could only carry out 1 read or write operation at a time. Before that I held an incorrect notion of what multitasking was.

My basic question is, has anything changed?

I hear terms like parallel processing being waved around as though daring me to infer that processors these days can write to more than 1 memory address at the same time.

To clarify once more. I'm talking about at the same exact time. Not during a clock tick. Actual simultaneity.


r/computerscience 6d ago

General Suggest books that bridge the gap between pop science and textbooks.

1 Upvotes

Similar books: Grokking's Algorithms, Inside The Machine, Code by Charles Pretzold.


r/computerscience 7d ago

Advice Looking for recommendations for computer science content to watch.

20 Upvotes

Someone who goes over computer architecture or even a network switch, in an enthusiastic and structured way. Just looking for general content to watch as a refresher.


r/computerscience 7d ago

Discussion question about RAM

37 Upvotes

Im learning about comuter components I had some questions .If a Hard Drive stores all the data does RAM just create an environment for the specific program that was fetched to run? If you were to run a program on the actual hard drive is it just harder because you have to navigate through all the other information sharing the space. Like going through a maze constantly again and again. Also what does SSD do?


r/computerscience 7d ago

hi dumbass here

0 Upvotes

I want to ask real humans this question. How do LLMs and other automated programming models deal with integer overflow? Even when coding games some time basic math for calculating level changes can crash systems and servers. So how often does this happen with these machines and data centers?


r/computerscience 9d ago

Discussion How are folders with files in it being stored in data?

45 Upvotes

I know that folders and files are saved as binary code in memory via hard drive, usb sticks, RAM, ect.

I dont know know about folders. On the internet there's no answer other than "as binary in memory" but I already know that, how are folders being saved as data?

My first thought was, that in every file, there's information for where its stored, but what about empty folders? What file says that that folder exists?

edit: now with the help of the guys in the replies, i now know how they work. with something called "inodes" on some opperating systems


r/computerscience 10d ago

Advice How to solve problems

14 Upvotes

Hello, I am an undergraduate computer science. I finished a course about complexity classes, algorithms and reductions. I am looking for information/literature on how to use this theory to apply it to any problem. I don't have a lot of knowledge about it, outside of the theoretical definitions I learned like the classes P and NP.

To illustrate, I give an example of a problem: "What is the minimum amount of digits needed in a sudoku grid to ensure that there exists a unique solution?"

Given a problem like this, I would like to be able to:

- Classify the difficulty of the problem in some way

- Determine whether a solution exists, and if so, if it can be found

- Apply generic methods, heuristics, reductions... to find a solution

In general, I'm wondering how many methods one needs to know to tackle most problems like this. I'm looking for literature from a mathematical or computational point of view.

Thanks in advance


r/computerscience 10d ago

General What are the limits of lock-free data-structures?

21 Upvotes

When I look at various lock-free data structures, I always see versions of the traditional data structures in their lock-free forms (queues, stacks, etc..). I was wondering if there are any data structures that are not possible to be implemented in a thread-safe manner without locks, or what the limits are of lock-free data structures. thx


r/computerscience 13d ago

What term would better fit Computer Science as a field of study?

46 Upvotes

r/computerscience 12d ago

Help Genetic Algorithms vs PPO

Thumbnail
0 Upvotes

---

*TL;DR: How does a PPO keep track of the relationships between input neurons, output neurons, weights, desired result and actual result? Does it save in disk every single possible combination?


r/computerscience 13d ago

Back in 2013, this video got me into Computer Science. Thankful I landed a good software career. Looking back at it today though, would you say it's outdated?

Thumbnail youtu.be
18 Upvotes