28
votes
What was the reason of the non-preemptivity of older Linux kernels?
In the context of the Linux kernel, when people talk about preemption they often refer to the kernel’s ability to interrupt itself — essentially, switch tasks while running kernel code. Allowing this ...
22
votes
Accepted
Does `at` run a command later if the computer is off at the specified time?
at executes any command that should have been executed before when you wake up the computer, but may take a few minutes to do that. It doesn't even matter whether you gave it a specific date, as you ...
17
votes
Start/stop a systemd.service at specific times
To stop a service A with a timer, you can create a service B of type oneshot that it will be in conflict with, then use a timer to start the service B.
If a unit has a Conflicts= setting on another ...
16
votes
Using and understanding systemd scheduling-related options in a desktop context
CPUScheduling{Policy|Priority}
The link tells you that CPUSchedulingPriority should only be set for fifo or rr ("real-time") tasks. You do not want to force real-time scheduling on services.
...
14
votes
Accepted
Linux timer interrupt
The Linux timer interrupt handler doesn’t do all that much directly. For x86, you’ll find the default PIT/HPET timer interrupt handler in arch/x86/kernel/time.c:
static irqreturn_t timer_interrupt(...
12
votes
What was the reason of the non-preemptivity of older Linux kernels?
Preemptive kernel only means that there is no Big Kernel Lock.
Linux had preemptive multi-tasking (i.e. user code was preemptible) since its first moment (as far I know, the very-very first Linux 0.0....
12
votes
Accepted
How does the kernel scheduler know how to pre-empt a process?
"The kernel is not a process."
This is pure terminology. (Terminology is important.) The kernel is not a process because by definition processes exist in userland. But the kernel does have threads.
"...
11
votes
Run script every 30 min with systemd
The proper way is to use systemd-run you can schedule your job without the need to define your own unit.
It allows you to schedule by a calendar or every period of time. Assuming MYSELF is your full ...
10
votes
Accepted
Understanding Linux Perf sched-switch and context-switches
I know this question is pretty old (Feb 16) but here a response in case it helps someone else.
The problem is that you've entered the '-F 999' indicating that you want to sample the events at a ...
10
votes
Understanding overhead cost of context switching
There are as many answers to this as there are operating system versions. No single answer covers everything.
Basically, the cost of context switching is the cost of saving all of the cpu state ...
9
votes
Accepted
systemctl cannot access service file, Permission denied
Set SElinux to permissive:
setenforce 0
This will disable it temporarily. Test again after disabling it, and see if this solves the issue.
To disable it permanently (Source), in the /etc/selinux/...
8
votes
Accepted
How to recover deleted crontab
You can find your cron jobs from the log if once it has executed before. Check /var/log/cron.
You do not have any recovery option other than third party recovery tools.
7
votes
Accepted
Does Linux 3.10 CFS have "timeslices"?
CFS doesn't have timeslices "in the way the previous scheduler had".
In CFS a timeslice is basically the duration between consecutive switches to grant CPU execution time to the same thread. This ...
7
votes
Accepted
What's the process scheduler in Linux?
In Linux, the process scheduler is a core part of the kernel. It doesn’t exist as a separate thread, or module, it’s implemented as a function, __schedule().
The job of the process scheduler is to ...
7
votes
How to make a system suspend and resume on schedule?
I've created a shell script for this purpose using systemctl suspend and rtcwake commands to manage the power.
When run, it'll work in a loop (15 minute cycles):
checking what time and day of week it ...
7
votes
Schedule command to run at specific timestamp with systemd
systemd-run can schedule a command to be run at a specific time, as long as:
the system is not powered down before that time, because it writes a transient timer & service file to /run, which is ...
7
votes
Accepted
Should I attempt to 'balance' my threads or does linux do this?
Linux:
The Linux kernel have a great implementation for the matter and have many features/settings intended to manage the ressources for the running process (over CPU governors, sysctl or cgroup), in ...
7
votes
Accepted
When will an interval cron execute the first time? (Ex: */3 days)
The crontab(5) man page use a wording that is pretty clear:
Step values can be used in conjunction with ranges. Following a range with "/number" specifies skips of the number's value ...
6
votes
Accepted
Are processes in square brackets scheduled in the same way as other processes?
Under Linux, ps and top handle information made available by the kernel in /proc, for each process, in a directory named after the pid. This includes two files, comm and cmdline; comm is the process’s ...
6
votes
What is the hardware which the linux kernel uses for timer interrupt
I suspect you were reading this or something very similar (https://elinux.org/Kernel_Timer_Systems):
Timer Wheel, Jiffies and HZ (or, the way it was)
The original kernel timer system (called the &...
6
votes
When will an interval cron execute the first time? (Ex: */3 days)
Today (2020-07-31) is the perfect day to ask this question, because 30 has an awful lot of factors.
My understanding (from memory) is that (a) the * expands to the range 1-31, then (b) the /3 is a ...
6
votes
Accepted
What is a parked thread in Linux kernel?
CPU parking is a power saving feature that allows taking an idle cpu core offline so it stops consuming power. When there is demand for the cpu again, the cpu is unparked.
Before a cpu can be parked, ...
5
votes
Accepted
Using taskset to set processor affinity
taskset uses a mask to specify which CPUs a process can run on. Each bit maps to one CPU; if a bit is set to 1, the process can run on that CPU, if it’s set to 0, it can’t. Thus a mask of FF means any ...
5
votes
Accepted
Linux scheduling overhead in orders of magnitude?
The default scheduler on Linux hasn’t been the O(1) scheduler for the last ten years, it’s the Completely Fair Scheduler, which is O(log n) on the number of tasks in the runqueue. You’d have to ...
5
votes
iptables rule to unblock internet acess, and block it again 3600 seconds later
You could use at :
sudo at next hour -f myiptablesscript
where myiptablescript had the command to disable access, or on one line as something like
sudo at next hour -f /dev/stdin <<< "...
5
votes
Cron expression at 11h30 and 19h every day
Just add two lines:
30 11 * * * some-command
0 19 * * * some-command
To factorise the code to avoid having to repeat it, you could store it in an environment variable:
CODE = some sh code here
30 11 ...
4
votes
@hourly vs 0 * * * * - Cron - How to run jobs hourly, but at different times
You may also explicitly limit your time boundaries using the modulus operator.
This is how to do it if you want to limit the launch to max 10 minutes (600 sec):
$RANDOM % 600 will yield results ...
4
votes
Why sudo user can use sched_setscheduler SCHED_RR while root can not?
I also got hit by this problem. In my case it turned out that docker daemon has reconfigured default cgroups. As a result root user had cgroup slice with cpu.rt_runtime_us set to zero. In order to set ...
4
votes
Why is Linux allowed to become unresponsive?
There is a workaround for the thrashing problem: to automatically limit system ressources per process user you can utilize the pam_limits module (via limits.conf) on Linux (CentOS and similar) or ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
scheduling × 422linux × 137
cron × 77
linux-kernel × 63
process × 53
kernel × 39
cpu × 24
real-time × 24
priority × 24
at × 23
nice × 21
shell-script × 19
ubuntu × 16
io × 15
interrupt × 14
multithreading × 11
thread × 11
systemd × 10
top × 8
cgroups × 8
shell × 7
command-line × 7
performance × 7
process-management × 7
pthreads × 7