Wikipedia:Reference desk/Archives/Computing/2019 July 28

= July 28 =

Is there a place where I can find the list of cpu ordered by l1 cache, and l2 cache and l3 cache?
Is there a place where I can find the list of cpu ordered by sram l1 cache, and sram  l2 cache and sram  l3 cache?

I want to see the cpus with most of those caches...179.197.136.39 (talk) 03:05, 28 July 2019 (UTC)


 * We have Comparison of AMD processors and List of Intel microprocessors, but the tables don't seem to be sortable.  Dbfirs  20:03, 28 July 2019 (UTC)


 * Those don't always show L1 and L2. You may need to look at more detailed articles such as List of Intel Core i7 microprocessors and List of Intel Xeon microprocessors. Bubba73 You talkin' to me? 23:45, 3 August 2019 (UTC)

UNIX pipe - parent reads children
My copy of Steven's APUE is in the office, and before I figure it out on my own, I was wondering if someone has a pointer ready. I have a parent process that forks off children. I want the parent to read the standard output of each child (essentially to buffer it away and then eventually print the "best" answer from any of children). I do know how to use select or poll for the multiplexing, but how can I get a FILE* (or fileno) handle that represents the child's stdout? I've set this up in similar situations with popen and just running the new process from scratch. But in this case, there is a significant amount of work (both logically and CPU-wise) that goes on in the parent before the fork, and I don't want to redo that work. Thanks! --Stephan Schulz (talk) 12:03, 28 July 2019 (UTC)


 * Create a pipe (with pipe(2)) before the fork. Then fork(2); the child inherits the pipe. The child can write to the pipe and the parent read it. To get the child's existing printfs (etc.) to stdout, use <tt>dup(2),</tt> to change its stdout (STDOUT_FILENO) to the pipe. -- Finlay McWalter··–·Talk 13:47, 28 July 2019 (UTC)
 * Thanks, I think from that I can figure it out. I'll report back on success (or failure ;-). --Stephan Schulz (talk) 14:30, 28 July 2019 (UTC)


 * On implementing it, you probably want <tt>dup2(2)</tt> instead. And if you're pointing buffered C output (e.g. printf) at the pipe, you may need to <tt>fflush(3)</tt> stdout before the data is actually sent into the pipe. I have a working, minimalish, example - let me know if you want the full code. -- Finlay McWalter··–·Talk 15:36, 28 July 2019 (UTC)
 * I'll probably hack my old example, but yours would certainly be welcome. One more question: What would be best practice for detecting termination of the child? Waiting or read returning 0 bytes?


 * https://github.com/finlay-mcwalter/pipe_example/blob/master/foo.c
 * wait is safer (and probably more ideomatic); in the above example, for simplicity, I just exit on a zero read -- Finlay McWalter··–·Talk 18:36, 28 July 2019 (UTC)
 * Thanks. It works. But why do both parent and child call ? Shouldn't one close  ? --Stephan Schulz (talk) 18:55, 28 July 2019 (UTC)
 * Really the child should probably close both after the dup2 call - as it already has a copy of the write end of the pipe connected to its stdout. Likewise if we were taking a copy in the parent (to dup the read end into the parents stdin) we could close both in the parent too. -- Finlay McWalter··–·Talk 19:07, 28 July 2019 (UTC)
 * I updated the github to that effect, and added waitpid -- Finlay McWalter··–·Talk 19:36, 28 July 2019 (UTC)