Skip to main content
15 votes

Can multi-threading improve performance of an IO-bound process?

I/O performance has two aspects that you must distinguish: latency and throughput. One measures how long you have to wait for the first byte of a response, the other how long you have to wait ...
Kilian Foth's user avatar
12 votes

Why is universal newlines mode deprecated in Python?

After stumbling across this question, I updated the documentation to be clearer about what's going on (https://github.com/python/cpython/pull/11646/files). The confusingly cryptic table entry for 'U' ...
ncoghlan's user avatar
  • 3,619
12 votes

How to Unit-Test a parser of a file?

I want to write tests for it. What you are intending to test? I want to use TDD. I'm refactoring a parser and want to test the 'parse()' method. So the aim is to clean things up. I would argue that ...
Arnis Lapsa's user avatar
10 votes

How does the Base Address Registers (BARs) in a PCI card work?

This question should be moved to stackoverflow. Maybe someone will do that. Am I correct? Essentially, yes. Each BAR holds the address of a communication area. This address can be set and read ...
Erik Eidt's user avatar
  • 34.4k
9 votes

How to Unit-Test a parser of a file?

This approach may work but as far as I understand from unit test methodology, unit-tests shouldn't perform I/O I think you are overlooking the elephant in the room here: your parser should not ...
nvoigt's user avatar
  • 8,445
8 votes
Accepted

Separate Thread Pools for I/O and CPU Tasks

To improve efficiency, I wanted to have one thread pool perform the I/O section and have it pass tasks to another thread pool that performs the CPU section. That way, it's unlikely that all threads ...
Blrfl's user avatar
  • 20.4k
8 votes
Accepted

What does "data bus control" mean?

Yes. The DMA controller takes ownership of the bus for the duration of the transfer. That said, I feel obliged to point out that at least on PC-based machines, DMA controllers have been almost ...
Jerry Coffin's user avatar
  • 44.7k
7 votes
Accepted

How data is accessed in Memory-Mapped I/O?

So basically you access the device controller registers through memory. Not exactly, which is why the diagram in the question doesn't quite depict memory-mapped I/O. Memory-mapped I/O uses the same ...
Blrfl's user avatar
  • 20.4k
7 votes

How do I apply TDD to read/write functions?

Start with the Read Function. In the test setup: create the database and add test data. either via migration scripts or from a backup. As this is not your code, it doesn't require a test in TDD In ...
Ewan's user avatar
  • 79.8k
6 votes

How do I apply TDD to read/write functions?

I often just do a write followed by a read. e.g. (pseudocode) Foo foo1 = setup some object to write File tempfile = create a tempfile, possibly in memory writeFoo(foo1, tempfile) Foo foo2 = ...
user949300's user avatar
  • 8,919
6 votes

How do peripherals decide which address to use in memory-mapped I/O?

It depends on the bus specification. For example, PCI uses an enumeration scheme whereby the OS probes for each possible device, and finding a device, asks it how many memory blocks it wants, and ...
Erik Eidt's user avatar
  • 34.4k
6 votes

What does "address space" means when talking about IO devices?

An Address Space is simply a range of allowable addresses. An I/O address is a unique number assigned to a particular I/O device, used for addressing that device. I/O addresses can be memory-...
Robert Harvey's user avatar
6 votes
Accepted

Are streams of binary data considered a form of bit banging?

Are streams of binary data considered a form of bit banging? No. The term bit banging is only used when referring to creating electrical signals on a processor pin. There are two ways to create the ...
Bart van Ingen Schenau's user avatar
6 votes

Can multi-threading improve performance of an IO-bound process?

If you are truly I/O bound, such as your network link being saturated, then no matter how many processes you run you will not be able to transmit requests and receive responses any faster. If you are ...
pjc50's user avatar
  • 14.8k
5 votes

What does "address space" means when talking about IO devices?

The basic idea is pretty simple: a chip can have one bus to connect to memory, and a second bus to connect to I/O devices--or it can share a single bus between the two. In practice, even a CPU that ...
Jerry Coffin's user avatar
  • 44.7k
5 votes

Separate Thread Pools for I/O and CPU Tasks

ioService must not be of availableCores() size. Its size depends on network characteristics of a computer and may even be unbounded. Don't block or wait, this wastes time. Submit a Runnable to ...
Miha_x64's user avatar
  • 151
5 votes
Accepted

How does disk wiping software access my hard disk?

The kernel has a very defined API for file handling Right. And that API includes other more granular capabilities. There is an API to allow access to e.g. format a drive, get model and serial ...
whatsisname's user avatar
  • 27.7k
5 votes

Can multi-threading improve performance of an IO-bound process?

Let's say the application is talking with some API, and has to make various API calls. If we have multi-threading, we can make those API calls in parallel, and boost the performance. This is correct. ...
JimmyJames's user avatar
  • 28.9k
5 votes
Accepted

What does it mean to be "truly" asynchronous?

Here it just means that while the I/O operations themselves may be asynchronous, the completion events are dispatched synchronously in Windows (ie, when you check the completion port). UNIX signals ...
Useless's user avatar
  • 12.7k
4 votes

How do I apply TDD to read/write functions?

Don't. Don't unit test I/O. It is a waste of time. Unit test logic. If there's a lot of logic that you want to test in the I/O code, you should refactor your code to separate the logic of how you do ...
mrr's user avatar
  • 919
4 votes

How to Unit-Test a parser of a file?

as far as I understand from unit test methodology, tests shouldn't perform I/O You have to distinguish which kind of tests you are talking about: if you want to use TDD with small "write test" - "...
Doc Brown's user avatar
  • 214k
4 votes

Can the CPU manipulate the pins of an IO port directly?

Based on what I know so far, when you plug an IO device into an IO port (for example, when you plug a printer into a parallel port), the printer will be represented to the CPU as just another RAM ...
Brendan's user avatar
  • 3,995
4 votes
Accepted

One thread for all database operations or one thread for each db operations?

Is it a good solution ? or not ? and why ? Databases have been among us for a long time, and a lot of people already did the thinking for us ;) You have a problem of Transactional Serializability. ...
linuxunil's user avatar
  • 1,461
4 votes
Accepted

Reading huge (up to 32 GB) file in multithreading env?

Accessing one file by multiple threads for reading 1MB chunks is trivial, just determine the file length and the number of chunks beforehand. Queue up the the chunks and let them process in parallel ...
Doc Brown's user avatar
  • 214k
4 votes
Accepted

Sequential or parallel access to hard disk in multithread program?

Assuming all are to the same disk, all read and writes will ultimately be performed one at a time. Assuming each file takes about the same amount of time by itself, your job overall will take about 4x ...
whatsisname's user avatar
  • 27.7k
4 votes

Sequential or parallel access to hard disk in multithread program?

It is hard to tell what will ultimately happen at the drive level. In between your Java program and the physical head(s) of the hard drive there will be multiple stages of buffering and scheduling ...
Martin Maat's user avatar
  • 18.5k
4 votes

Applying function to file line by line or read entirely into structure first?

You can always measure, but you might be surprised at the results, especially for sequential access. People don't think about optimizations done at lower levels of abstraction. For example, your ...
Karl Bielefeldt's user avatar
4 votes
Accepted

Best way to reduce database writes?

Assuming that you really need this counter, does it really have to be constantly updated every time a user sends a message? Could you use a more "granular" counter which increments every ...
Alex D's user avatar
  • 1,308
4 votes
Accepted

Operating systems - whose responsibility is it to coordinate process I/O requests?

A blocking system call will simply not return control to the process that called it. Either the data will become available during the time slice that the scheduler allocated to that process, so that ...
Kilian Foth's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible