Programs sit on disk.
Maybe not run for years.
- An instance of the program running.
- 1 user. 1 program. n processes.
- n users. Shared memory. 1 program. n processes.
- Example: Login to student server.
Lots of users running nano.
ps -Af | grep nano
- 1 program. n processes. All running in memory space of student server.
All protected from each other.
- n users. Common file system but not shared memory. 1 program. n processes.
- Example: n users on lab PCs.
Lots of users running a program from /users
All running the same copy from somewhere in /users
- n processes.
Each in different memory space on its own PC.
- Task Manager
- Show information about running processes.
When system running slow, look for culprit.
Q. What are common culprits?
- Sysinternals page at Microsoft has many tools to download, including:
List processes in Task Manager on Windows 10.
Can sort columns.
Shown here is sort by memory usage.
In the "Details" tab of Task Manager you can look at a range of features of each process.
Right click the top bar and "Select columns" to select the columns to show.
You can sort on any column.
Here sorted on Page faults.
Loaded from disk (permanent, power-off storage)
into memory (RAM).
May pause when doing disk I/O, waiting on user event, etc.
Does not always have work for CPU to do.
May pause for long time.
READY to RUNNING -
Short-term (CPU) scheduler
decides if you can run now.
RUNNING to WAITING - I/O or event wait.
WAITING to READY - I/O or event completion.
It is often the case that processes are idle for a long time.
e.g. A GUI process waiting on user input, that the user has not looked at in hours.
If running short on RAM, and process has not run for a long time, it may be removed from RAM to disk.
(Or parts of it may.)
This is called Swapping to disk.
It is the running copy on disk.
Not the same thing as the original program file.
If you click on the program again, there may be a delay as the OS gets it back from disk.
Swapping is integrated with Paging
2 (or more) flows of control in the same process.
2 (or more) instruction counters.
Same memory (same data and code space).
e.g. Web server - Each request is a separate thread,
all running in parallel until request completed.
Web browser - multiple windows downloading at same time.
Each is a separate thread in same process.
Modern computers have
(multiple processing units, executing instructions in parallel).
Modern OS will schedule threads and processes
across multiple cores.
- The idea that once a process or thread starts running on one core,
it is often more efficient to leave it there
(and its data in the core's
rather than change cores.
Cores on Linux
On Linux we can look at multiple core use from command-line using
ps and top
and other commands.
Display number of cores available:
Show info about the multiple cores:
$ cat /proc/cpuinfo
Run process using core n (where n is 0 to 3 here):
$ taskset -c n prog
See what processes are currently using what cores:
$ ps -Ao user,pid,ppid,comm,psr
USER PID PPID COMMAND PSR
root 1 0 init 0
root 2 0 kthreadd 2
root 3 2 ksoftirqd/0 0
root 25 2 watchdog/3 3
root 328 1 udevd 3
humphrys 29858 29855 sshd 0
humphrys 29859 29858 csh 0
humphrys 32373 29859 ps 1
humphrys 32374 29859 grep 1
# PSR will be 0 to 3 here
Query if process is bound to a core:
$ taskset -p 3
pid 3's current affinity mask: 1
$ taskset -p 25
pid 25's current affinity mask: 8
# 0001 (1) - bound to core 0 (see process 3 command /0)
# 0010 (2) - bound to core 1
# 0100 (4) - bound to core 2
# 1000 (8) - bound to core 3 (see process 25 command /3)
$ taskset -p 1
pid 1's current affinity mask: f
# 1111 (f) - can run on all 4 cores, not tied to any core
See load on different cores:
(and then press 1)
The OS logs (in a file) events connected to processes.
- I had issue on Windows with hidden application stealing focus and returning it.
- Installed Window Focus Logger
- This told me the focus stealer was
Werfault - Windows Error Reporting system.
- This meant some application was constantly generating errors.
- Event Viewer - Windows Logs - Application. This showed the application generating the errors.
- Delete the application.
- Unix syslog.
- On Unix/Linux, various text and binary format logfiles are in:
- Text logfile example:
- fail2ban logfile is text format.
On student server we used to be able to look at it, but not any more:
tail -20 fail2ban.log
- Binary logfile examples: We can read the following files (all binary files, need to run certain programs to read them).
lastlog - user logins on Unix/Linux