It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
Is it possible to use /proc within a C programm to provide information about the internal state?
For example I contribute the handle internalInfo that a cat /proc/2382/internalInfo outputs me information I would otherwise have to retrieve by e.g. sending a signal to the process to generate the information into the logfile and then parse the logfile etc.
The purpose of procfs : "providing a more convenient and standardized method for dynamically accessing process data held in the kernel" (http://en.wikipedia.org/wiki/Procfs).
In this sense, procfs is to expose the kernel's information about a process, it is not to be used as interprocess communication in user space.
To specifically answer the question: yes, you could expose information about your process to processes using procfs -- this should only be done if the information that is needed is kept within the kernel. procfs should not be used if the information you are trying to access is maintained by the process itself in userspace -- I recommend using some other kind of communication method such as pipes, shared memory, files, or signals.
Related
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
Any help would be most welcome...
Thank you ^^
Simulation is the imitation of the operation of a real-world process or system over time.1 The act of simulating something first requires that a model be developed; this model represents the key characteristics or behaviors of the selected physical or abstract system or process. The model represents the system itself, whereas the simulation represents the operation of the system over time.
Benchmarking is the process of comparing one's business processes and performance metrics to industry bests or best practices from other industries. Dimensions typically measured are quality, time and cost. In the process of benchmarking, management identifies the best firms in their industry, or in another industry where similar processes exist, and compare the results and processes of those studied (the "targets") to one's own results and processes. In this way, they learn how well the targets perform and, more importantly, the business processes that explain why these firms are successful.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
I need to print a call stack in log file in a running program (in C) as I need to check the flow,
I have to send traces to other environment and I can't debug, Is there any way to do it in C.
If the platform is linux (and I believe in OSX too), you could use backtrace and backtrace_symbols to achieve what you want.
As per the notes section of backtrace
The symbol names may be unavailable without the use of special linker
options. For systems using the GNU linker, it is necessary to use the
-rdynamic linker option. Note that names of "static" functions are not exposed, and won't be available in the backtrace.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I am trying to handle a deadlock situation and need to restart a deadlocked thread from the monitor thread by resource pre-emption and rollback strategy for posix threads..Im clueless about how to restart a thread from another thread ,Kindly help!
I don't think "restarting" is a common and well-defined operation provided by typical thread implementations. I certainly didn't find any in pthreads, which I assume you're using.
What would a "restart" involve, exactly? How is it different from (somehow) destroying/stopping the thread, and starting a new one with the same code and data?
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I have begun writing (in C) a small client/server application which relies on TCP. I lack any experience in network programming. I'm sorry for the open-ended character of this post.
I'm wondering how best to encode and decode messages. I've chosen the following approach:
The client sends commands to the server. Every command has a number assigned to it and a struct. The struct stores the command's arguments and the way the arguments are laid out in memory (and in the stream as well). When the client wants to send a command, it fills the respective struct with data. In order for the server to recognize the command, the client sends one byte which contains the command number. Right after the command number byte, the message itself is fed to the stream (with its fields properly converted to network byte order).
This approach led to working code, but it entails a lot of redundancy (I find myself writing switch statements over and over). Is there a better way? What's the standard procedure?
Google's Protocol Buffers are a nice way to serialize/deserialize data. There are implementations for C.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 12 years ago.
I am reading the C programing guide and all of a sudden it starts talking about pipes. Can someone simply tell me what a pipe is.
They are OS objects appearing as file descriptors in different processes, allowing output of one to be the input of the other. Read here.
You want to read Beej's IPC Guide, specifically the pipe section.
There is no form of IPC that is simpler than pipes. Implemented on every flavor of Unix, pipe() and fork() make up the functionality behind the "|" in "ls | more". They are marginally useful for cool things, but are a good way to learn about basic methods of IPC.
Also check the other guides at http://beej.us/guide/.
Most likely, this means a Pipeline as in the context of Unix-like operating systems, see Pipeline (Unix) in Wikpedia. It is a chain of processes with the output of one process being the input to the next one.