#include <stdlib.h>
#include <stdio.h>
int x;
int y = 15;
int main(int argc, char *argv[]) {
int *values;
int i;
values = (int *) malloc(sizeof(int) * 5);
for (i = 0; i < 5; i++) {
values[i] = i;
}
return 0;
}
# the size (in bytes) of some of these sections
$ size program_name
The processes in the must systems can execute concurrently, and they may be created and deleted dynamically.
If you program using concurrent programming, it's not necessarily going to be executed as such (parallel execution), since it depends on the machine.
-- -- --
/ \
---- -- -- -- -- ----
------
/ \
--------------
# -l Display information associated with the following keywords: uid, pid, ppid, ...
# -e Display information about other uesrs' processes, including those without controlling terminals.
ps -el
pstree
top
htop
When a process creates a new process, two possibilities for execution
There are also two address-space possibilities for the new process
#include <stdio.h>
#include <unistd>
#define MAX_COUNT 200
#define BUF_SIZE 100
int main(int argc, const char *argv[]) {
pid_t pid;
int i;
char buf[BUF_SIZE];
fork();
pid = getpid();
for (i = 1; i ≤ MAX_COUNT; i++) {
sprintf(buf, "This line is from pid %d, value = %d\n", pid, i);
write(1, buf, strlen(buf));
}
int execl(char const *path, char const *arg0, ...);
int execle(char const *path, char const *arg0, ..., char const *envp[]);
int execlp(char const *file, char const *arg0, ...);
int execv(char const *path, char const *argv[]);
int execve(char const *path, char const *argv[], char const *envp[]);
int execvp(char const *file, char const *argv[]);
The first argument arg0 should be the name of the executable file.