Jump to content

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

From Wikipedia, the free encyclopedia
Computing desk
< July 27 << Jun | July | Aug >> Current desk >
Welcome to the Wikipedia Computing Reference Desk Archives
The page you are currently viewing is an archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages.


July 28

[edit]

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

[edit]

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)[reply]

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)[reply]
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)[reply]

UNIX pipe - parent reads children

[edit]

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)[reply]

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 dup(2), to change its stdout (STDOUT_FILENO) to the pipe. -- Finlay McWalter··–·Talk 13:47, 28 July 2019 (UTC)[reply]
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)[reply]
On implementing it, you probably want dup2(2) instead. And if you're pointing buffered C output (e.g. printf) at the pipe, you may need to fflush(3) 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)[reply]
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? Wait()ing 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)[reply]
Thanks. It works. But why do both parent and child call close(pipefd[1]);? Shouldn't one close pipefd[0]? --Stephan Schulz (talk) 18:55, 28 July 2019 (UTC)[reply]
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)[reply]
I updated the github to that effect, and added waitpid -- Finlay McWalter··–·Talk 19:36, 28 July 2019 (UTC)[reply]