All Questions

Tagged with
Filter by
Sorted by
Tagged with
1
vote
0answers
31 views

How to access a process descriptor that isn't the current one? [closed]

Is there any way to access a processes descriptor of a process that isn't currently running, preferably in C?
0
votes
1answer
59 views

Where does main function get allocated?

When concerned with a memory layout for a process, all function calls within the process get a new stack-frame into the stack. I'm not sure if this is true for main function as it seems like main ...
-1
votes
2answers
71 views

Child processes seem to run code from before they were created. How do I stop it?

I'm trying to write a program that has a single parent process create multiple children in a while loop. For testing I started trying to make only 4 processes (1 parent and its 3 children). But it ...
1
vote
3answers
75 views

Strange zombie process responds to signals?

I have a strange situation. I have a c-written program “A” which takes as argument the name of other executables, e.g. “B”, “C”, “D” etc.. The main job of “A” is to fork and start “B”, “C” etc, then ...
1
vote
0answers
243 views

Mutual exclusion between all Linux threads and processes [closed]

I'm trying to write a piece of code that should not been executed simultaneously neither by threads of the same process, nor by different processes. In other words, I need global synchronization ...
1
vote
1answer
68 views

Processor not seeing changes to POSIX shared memory?

Context: I am using POSIX shared memory to provide a set of processes with a shared memory space. I have used this scheme for some time now in order to share data, and it's working okay. However, I ...
0
votes
1answer
90 views

What codes are copied to the child process?

If we call the method fork() inside an if statement, does the generated child process enter into the else statement ? #include <stdio.h> #include <unistd.h> #include <stdlib.h> #...
1
vote
2answers
938 views

File Operations and Processes

Is it possible that two different processes(parent and child) can see the same text file and manipulate it ? I accomplished this, but I had to open the file in both processes by using fopen(). My ...
1
vote
1answer
151 views

Process and fork() Method

I am new to Operating Systems and Linux hence this may be very basic question but I cannot find an answer. According the resources I have read so far, the fork() method creates new process by ...
1
vote
1answer
916 views

Creating a specific process tree and terminating it

I am currently taking a Computer Systems class and am having trouble with a homework problem. I have to create this specific process tree: I also need it to stay in this state for a while (using ...
0
votes
1answer
101 views

How to make it so that parent creates child, exits before the child completes, then the orphan is re-parented by init?

#include <stdlib.h> #include <stdio.h> #include <sys/types.h> #include <unistd.h> #include <sys/wait.h> int main () { pid_t child_pid; child_pid = fork (); // ...
61
votes
7answers
17k views

Are threads implemented as processes on Linux?

I'm going through this book, Advanced Linux Programming by Mark Mitchell, Jeffrey Oldham, and Alex Samuel. It's from 2001, so a bit old. But I find it quite good anyhow. However, I got to a point ...
3
votes
0answers
86 views

C on Linux: Running 25 parallel processes is significantly quicker than running 24 [closed]

My C-program uses fork() to create new processes and I measure the time it takes for each one of these processes to do its work. In fact, I let them do the work 10000 times and measure that time. ...
0
votes
2answers
871 views

Sleep system call and its time parameter

Let's say that we are writing a C program that calls the sleep() function. For instance, by calling sleep(7), the calling thread would be put to sleep for 7 seconds. My question is: Will the thread ...
0
votes
1answer
4k views

Process tree using fork() [closed]

I am given the task of creating this process tree in C using fork, if and else: |_____1___ |___2__ | |_4_ | |_3_ | | | | | Or as a pstree like drawing: p(0)─┬─p(1)───p(3) ├─p(2) ...
3
votes
1answer
3k views

Why does a “child” process finish before its parent?

This is the code example given: # include <stdio.h> # include <unistd.h> void main() { static char *mesg[] = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"}; int display(char *)...
6
votes
3answers
4k views

How does getpid work?

The getpid system call returns the process id of the invoking process. How does the kernel figure out which process is invoking the system call ?
8
votes
4answers
12k views

chdir(<directory>) doesn't change directory after exiting to shell

I wanted to make a simple C program to change to my project directory. Its content is as follows: #include <unistd.h> int main() { chdir("/home/enedil/projects/algo"); return 0; } I ...
3
votes
1answer
179 views

Is each process considered a thread?

Is a Linux process considered a thread? For example, if I write a simple c program that calls pthread_create to create a new thread in main(), does that mean that I now have 2 threads, one for main()...
2
votes
2answers
4k views

How to make processes not die after its parent dies?

I've been messing with forkbombs and noticed that if I just fork() processes repeatedly, killing the initial process will bring down the whole tree. This is not the case for forkbombs written in BASH ...
1
vote
1answer
812 views

How to trace process scheduling of certain process?

For a project at my university I am researching ways to trace, log and manipulate the process scheduling of certain processes. I would like to launch an number of applications, everyone in a single ...
0
votes
2answers
574 views

Which process updates /proc/scsi/scsi?

I wrote C that displays info about my hardware on ubuntu. Now I wonder how I can make it more flexible such as querying the hardware directly instead of the file the os updates. So I think I can look ...
-4
votes
2answers
124 views

Which Linux distro/mode offers lowest interference when running your own applications?

I'm interested in a Linux distro to build C projects and test their behavior in a very predictable and controlled environment. I'm especially concerned about letting the scheduler deal as much as ...
5
votes
3answers
2k views

Why is there a type for process ids (pid_t), but not for file descriptors (fd)?

I see that pid_t is typedef'd in unistd.h, and file descriptors are defined to be int in fcntl.h. But since they are used in similar ways, wouldn't it make sense to have a typedef for file descriptors?...
21
votes
4answers
19k views

After fork(), where does the child begin its execution?

I'm trying to learn UNIX programming and came across a question regarding fork(). I understand that fork() creates an identical process of the currently running process, but where does it start? For ...
2
votes
1answer
308 views

Recording and charting boot process information in Linux

I need to write a command line tool that records the boot process information in Linux, and then renders it in a chart format (a textual chart would do). How do I programmatically obtain the this boot ...