posix

What is the status of POSIX asynchronous I/O (AIO)?

纵然是瞬间 提交于 2019-12-17 06:22:23
问题 There are pages scattered around the web that describe POSIX AIO facilities in varying amounts of detail. None of them are terribly recent. It's not clear what, exactly, they're describing. For example, the "official" (?) web site for Linux kernel asynchronous I/O support here says that sockets don't work, but the "aio.h" manual pages on my Ubuntu 8.04.1 workstation all seem to imply that it works for arbitrary file descriptors. Then there's another project that seems to work at the library

Distinguishing between Java threads and OS threads?

拈花ヽ惹草 提交于 2019-12-17 05:34:25
问题 How do I distinguish running Java threads and native threads? In Linux there will be Parent process for every child process, and they say 0 is the parent of all the process, will there be a Parent thread of all the forked Java threads? How do I know which Java thread is related to OS thread (if a Java thread forkes a native process thread). Is there any naming convention of Java threads and OS threads? Can a running Java threads can be suspended or killed from another Java code? 回答1: On Linux

Using threads, how should I deal with something which ideally should happen in sequential order?

旧时模样 提交于 2019-12-14 03:58:56
问题 I have an image generator which would benefit from running in threads. I am intending to use POSIX threads, and have written some mock up code based on https://computing.llnl.gov/tutorials/pthreads/#ConVarSignal to test things out. In the intended program, when the GUI is in use, I want the generated lines to appear from the top to the bottom one by one (the image generation can be very slow). It should also be noted, the data generated in the threads is not the actual image data. The thread

POSIX analog of coreutils “stat” command?

坚强是说给别人听的谎言 提交于 2019-12-14 03:58:42
问题 Coreutils stat have --format= switch which report different info about file (owner, size, etc) in easy form for readers. POSIX ls utility provide most of this info, but its output is hard to parse. Compare with one-liner: [ `stat -c '%U' $f` = $USER ] && echo "You own $f" || echo Error! Are there stat utility analog in POSIX? 回答1: The short answer is no , POSIX does not provide a simple way to get the same output as stat . However, you can usually get relevant bits using other tools. To get

Physical disk block size on POSIX using C/C++

早过忘川 提交于 2019-12-14 03:39:41
问题 I'm working on a high performance I/O program and I'm trying to find the best way to determine the physical (and not the logical ) byte size of a device's disk blocks with C++. My research so far has led me to the following code snippet: #include <iostream> #include <sys/stat.h> #include <stdio.h> #include <errno.h> int main(int argc, char ** argv) { // file information including block size of the device struct stat info; // device to get block size from char * device = "/mnt/hdb1"; if (stat

Recommended signals to catch?

柔情痞子 提交于 2019-12-14 02:26:52
问题 Currently, I catch SIGSEGV, send myself an email, and then abort() so I can get a core file and debug my program. (If I did not catch, there would be no way that I would not know that my particular program segfaulted. My program is run in a separate server from my own.) Are there any other signals that I should catch for debugging or for reasons that I should know about ? 回答1: What makes you think that a SEGV hasn't already corrupted your program memory so much that an attempt to send email

Is there anything like shm_open() without filename?

断了今生、忘了曾经 提交于 2019-12-14 01:42:32
问题 The POSIX shm_open() function returns a file descriptor that can be used to access shared memory. This is extremely convenient because one can use all the traditional mechanisms for controlling file descriptors to also control shared memory. The only drawback is that shm_open() always wants a filename. So I need to do this: // Open with a clever temp file name and hope for the best. fd = shm_open(tempfilename, O_RDWR | O_CREAT | O_EXCL, 0600); // Immediately delete the temp file to keep the

Find number of tasks blocking on a POSIX semaphore

时光毁灭记忆、已成空白 提交于 2019-12-13 21:34:39
问题 Is there any way by which I can know the number of processes or threads waiting on a particular semaphore? Like a API to check the value. Sem_getvalue() only returns 0 and not a negative number whose absolute value is the number of tasks blocking on the semaphore as mentioned on a few sites. Any help would be great. Thanks in advance!! 回答1: There is no way to do this in the POSIX API other than sem_getvalue , which semantics, as you have seen, are optional. That said, Linux implements named

Calling times() in kernel space

╄→гoц情女王★ 提交于 2019-12-13 16:08:46
问题 I am developing a kernel module, and I need to get an approximate value of the CPU time consumed by some process (iterating the processes is not an issue). Specifically, I want the same behavior provided by the libc clock or the times syscall. I tried calling do_sys_times but seems it's not exported (undefined symbol when compiled). Is there a way to call times inside a kernel module? Are there any other alternatives? 回答1: If you want precisely measure times between some events in kernel

c library function to get number of active threads

萝らか妹 提交于 2019-12-13 14:16:33
问题 I'm developing a multi threaded Unix application in C. Is there a simple way to get the count of the number of simultaneously active threads? I don't want to have to write the code to keep track of the number of active thread if it already can be done for me by the library! :-) I'm using POSIX pthreads, and I'm trying to write as portable as possible code for Unix and Unix-like systems. 回答1: No, not in pthreads per se . POSIX Threads tries to specify only primitives or basic utility