DEVTOME.COM HOSTING COSTS HAVE BEGUN TO EXCEED 115$ MONTHLY. THE ADMINISTRATION IS NO LONGER ABLE TO HANDLE THE COST WITHOUT ASSISTANCE DUE TO THE RISING COST. THIS HAS BEEN OCCURRING FOR ALMOST A YEAR, BUT WE HAVE BEEN HANDLING IT FROM OUR OWN POCKETS. HOWEVER, WITH LITERALLY NO DONATIONS FOR THE PAST 2+ YEARS IT HAS DEPLETED THE BUDGET IN SHORT ORDER WITH THE INCREASE IN ACTIVITY ON THE SITE IN THE PAST 6 MONTHS. OUR CPU USAGE HAS BECOME TOO HIGH TO REMAIN ON A REASONABLE COSTING PLAN THAT WE COULD MAINTAIN. IF YOU WOULD LIKE TO SUPPORT THE DEVTOME PROJECT AND KEEP THE SITE UP/ALIVE PLEASE DONATE (EVEN IF ITS A SATOSHI) TO OUR DEVCOIN 1M4PCuMXvpWX6LHPkBEf3LJ2z1boZv4EQa OR OUR BTC WALLET 16eqEcqfw4zHUh2znvMcmRzGVwCn7CJLxR TO ALLOW US TO AFFORD THE HOSTING.

THE DEVCOIN AND DEVTOME PROJECTS ARE BOTH VERY IMPORTANT TO THE COMMUNITY. PLEASE CONTRIBUTE TO ITS FURTHER SUCCESS FOR ANOTHER 5 OR MORE YEARS!

Processes

Hayek's Linux Manual

A process is a program in execution

Description

A process consists of executing program code, resource sets (files), kernel data, address space, one or more threads and data for global variables.

Processes have attributes that hold information in memory. For example, PID, state, parent process, children, siblings, processor registers, open files and address space information.

The linux kernel maintains running processes with a circular doubly linked list. *init* is the mother of all Linux processes, you could say it resides at the beginning of the list. However, because it is circularly linked there is technically not beginning/end. Each processes maintained by the kernel is stored as a task_struct data structure.

Attributes

States

A process can have the following states:

  • Running
    • The process is running or ready to run (waiting to be assigned a CPU)
  • Waiting
    • The process is waiting for another event to finish or waiting for a system resource. Linux uses Interruptible and Uninterruptible to designate between each. A process cannot be interrupted if it is waiting directly on hardware conditions.
  • Stopped
    • The process been stopped. Debugging can put a process in to the stopped state.
  • Zombie
    • This process is halted for some reason but still has a spot in the process list.

Scheduling Information

This is how the simultaneous execution effect is achieved. Scheduling information is used to switch between processes in a very short period of time. The schedule follows a policy.

Linux scheduling uses a time sharing technique. The CPU is divided in to slices for each runnable process. Each process is associated with a value that denotes how it is assigned to the CPU.

There are three types of processes

  • Interactive Process
    • Any process that interacts with a user is an interactive process. It has to be responsive to input that is received but it may spend a lot of time waiting for keypresses.
  • Batch Processes
    • Usually these are commands being run in the background. They don't need to wait for user interaction and don't rate as high to the scheduler as other processes. A batch process is bound to Input/Output or to the CPU, database and rendering programs respectively. There is no way for Linux to distinguish between interactive and batch programs. To provide good response time to interactive apps Linux favors I/O bound processes over CPU bound ones (This is why your computer chugs when you open too many crypto wallets at the same time).
  • Real-Time Processes
    • These processes take priority over all others. They require the lowest response times and the least variance in response time. A program that collects data from environmental sensors or video/sound applications would require real-time processes.

Finally, the scheduler measures time in quantums. The quantum cannot be set too high/low.

  • Too low

If it takes the CPU 10 ms to switch between tasks and the quantum is set to 1ms it will take 11ms to execute each task. If we have ten tasks it will take 110ms with ~91% of that time spent by the CPU switching between tasks.

  • Too High

If it takes the CPU 10 ms to switch between tasks and the quantum is set to 2 seconds it will 2.001 seconds to execute each task. However, after running for a second the task will stop for n*2 seconds before it starts again.

Identifiers

Every process has a process identifier. It is just a number, not an index to the task list. Identifiers are also used for User and Group ids, similar to how file access is used on the system.

  • Process ID
    • PID, just a number
  • Parent Process ID
    • Identifies the process that created this one
  • GID
    • Group ID used to identify process groups that share the same process group id (piped commands)
  • SID
    • Session ID used to identify a group of processes in the same session
  • Real UID/GID
    • User/Group ID of the owner
  • Effective UID/GID
    • Used to determine the permissions of the processes for shared resources.
  • Saved set-UID / set-GID
    • A copy of IDs from when the process was executed
  • Filesystem UID/GID
    • Used to determined the permissions of the processes for accessing files
  • Supplementary GIDs
    • Used for checking the permissions accessing files and other shared resources.

A child process is created using fork

Inter-Process Communication

Signals, Pipes, Sockets, Unix Mechanisms, Semaphores, and Message Queues. Processes communicate with each other and the kernel through IPC.

  • Signals
     [hayek@localhost ~]$ kill -l
      1) SIGHUP	 2) SIGINT	 3) SIGQUIT	 4) SIGILL	 5) SIGTRAP
      6) SIGABRT	 7) SIGBUS	 8) SIGFPE	 9) SIGKILL	10) SIGUSR1
     11) SIGSEGV	12) SIGUSR2	13) SIGPIPE	14) SIGALRM	15) SIGTERM
     16) SIGSTKFLT	17) SIGCHLD	18) SIGCONT	19) SIGSTOP	20) SIGTSTP
     21) SIGTTIN	22) SIGTTOU	23) SIGURG	24) SIGXCPU	25) SIGXFSZ
     26) SIGVTALRM	27) SIGPROF	28) SIGWINCH	29) SIGIO	30) SIGPWR
     31) SIGSYS	34) SIGRTMIN	35) SIGRTMIN+1	36) SIGRTMIN+2	37) SIGRTMIN+3
     38) SIGRTMIN+4	39) SIGRTMIN+5	40) SIGRTMIN+6	41) SIGRTMIN+7	42) SIGRTMIN+8
     43) SIGRTMIN+9	44) SIGRTMIN+10	45) SIGRTMIN+11	46) SIGRTMIN+12	47) SIGRTMIN+13
     48) SIGRTMIN+14	49) SIGRTMIN+15	50) SIGRTMAX-14	51) SIGRTMAX-13	52) SIGRTMAX-12
     53) SIGRTMAX-11	54) SIGRTMAX-10	55) SIGRTMAX-9	56) SIGRTMAX-8	57) SIGRTMAX-7
     58) SIGRTMAX-6	59) SIGRTMAX-5	60) SIGRTMAX-4	61) SIGRTMAX-3	62) SIGRTMAX-2
     63) SIGRTMAX-1	64) SIGRTMAX

Signals are the oldest communication methods. A signal can come from a keyboard or an error. The shell uses signals for job control in child processes.

Normal processes can only send signals to processes with the same uid/gid. Processes belonging to the kernel or to root can talk to every other process.

When a signal is sent it is not acknowledged by the process until the next time that process is run.

  • Pipes

Pipes send the output of one command as input to the next. For example:

 cat * | grep hayek | wc

The content of all files are sent to grep which sends all lines containing 'hayek' to wc. The result would be the word/character count of all lines containing hayek.

  • Sockets

Sockets allow programs to communicate with one another across a network using IP, UDP and TCP.

  • Message Queue

System V implementation. Allows messages to be written/read to a queue by one or more processes.

  • Semaphores

A location in memory that can be set and tested by more than one process.

  • Shared Memory

Allows multiple processes to communicate via memory that appears in their address space.

 [hayek@localhost ~]$ pstree
 systemd─┬─NetworkManager─┬─dhclient
         │                ├─nm-openvpn-serv─┬─openvpn
         │                │                 └─{nm-openvpn-serv}
         │                └─3*[{NetworkManager}]
         ├─2*[abrt-watch-log]
         ├─abrtd
         ├─accounts-daemon───2*[{accounts-daemon}]
         ├─alsactl
         ├─at-spi-bus-laun─┬─dbus-daemon
         │                 └─3*[{at-spi-bus-laun}]
         ├─at-spi2-registr───{at-spi2-registr}
         ├─atd
         ├─atieventsd
         ├─auditd─┬─audispd─┬─sedispatch
         │        │         └─{audispd}
         │        └─{auditd}
         ├─avahi-daemon───avahi-daemon

Every process has a parent process except for init. Links are used to show this relationship

Virtual Memory

This is how the kernel tracks what virtual memory is mapped to the system's physical memory

Virtual memory is used to track all memory pages. Virtual memory is is managed by the Virtual Memory Manager & Memory Manager Unit. The MMU allows the operating system to access memory through a virtual address. It translates those addresses to physical addresses.

Times and Timers

When the process was created and how much CPU it's used.

Filesystem

Pointers to descriptors for each open file.

Process Specific Content

Used to store process information while a process is suspended.

Computing


QR Code
QR Code processes_hayek.0 (generated for current page)
 

Advertise with Anonymous Ads