sed - строка замены с содержанием файла

Когда количество мига увеличено затем, процесс заставляет время работать. Миг увеличен прерыванием по таймеру, которое говорит планировщику переносить. Миг определяет максимальный период времени для процессов для выполнения без перепланирования. Если процесс звонит yield() или sleep(), например, затем перепланирование сразу происходит. Таким образом контекстное переключение к следующему доступному рабочему процессу не обязательно происходит на границе мига.

Однако фактическое поведение ядра определяется во время компиляции ядра, linux/kernel/Kconfig.preempt:

choice
    prompt "Preemption Model"
    default PREEMPT_NONE

config PREEMPT_NONE
    bool "No Forced Preemption (Server)"
    help
      This is the traditional Linux preemption model, geared towards
      throughput. It will still provide good latencies most of the
      time, but there are no guarantees and occasional longer delays
      are possible.

      Select this option if you are building a kernel for a server or
      scientific/computation system, or if you want to maximize the
      raw processing power of the kernel, irrespective of scheduling
      latencies.

config PREEMPT_VOLUNTARY
    bool "Voluntary Kernel Preemption (Desktop)"
    help
      This option reduces the latency of the kernel by adding more
      "explicit preemption points" to the kernel code. These new
      preemption points have been selected to reduce the maximum
      latency of rescheduling, providing faster application reactions,
      at the cost of slightly lower throughput.

      This allows reaction to interactive events by allowing a
      low priority process to voluntarily preempt itself even if it
      is in kernel mode executing a system call. This allows
      applications to run more 'smoothly' even when the system is
      under load.

      Select this if you are building a kernel for a desktop system.

config PREEMPT
    bool "Preemptible Kernel (Low-Latency Desktop)"
    select PREEMPT_COUNT
    select UNINLINE_SPIN_UNLOCK if !ARCH_INLINE_SPIN_UNLOCK
    help
      This option reduces the latency of the kernel by making
      all kernel code (that is not executing in a critical section)
      preemptible.  This allows reaction to interactive events by
      permitting a low priority process to be preempted involuntarily
      even if it is in kernel mode executing a system call and would
      otherwise not be about to reach a natural preemption point.
      This allows applications to run more 'smoothly' even when the
      system is under load, at the cost of slightly lower throughput
      and a slight runtime overhead to kernel code.

      Select this if you are building a kernel for a desktop or
      embedded system with latency requirements in the milliseconds
      range.

endchoice

Да, Linux не может сказать, сколько операций было выполнено в 1 миге, поскольку различные инструкции занимают различные времена для выполнения, а также конвейерная обработка инструкций влияет на количество инструкций, выполняемых в единице времени.

22
20.08.2016, 17:52
3 ответа

Попробуйте использовать

join file1 file2

, а затем удалите все ненужные поля.

1
27.01.2020, 19:43

Здесь является решением sed :

% sed -e "s/localhost/$(sed 's:/:\\/:g' file2)/" file1
---
  host: "1.1.1.1"
  port: 3000
  reporter_type: "zookeeper"
  zk_hosts: 
    - "1.1.1.1:2181"

Вы должны использовать sed -i , чтобы внести изменения на месте.

Если вы можете использовать awk , вот один из способов:

% awk 'BEGIN{getline l < "file2"}/localhost/{gsub("localhost",l)}1' file1
---
  host: "1.1.1.1"
  port: 3000
  reporter_type: "zookeeper"
  zk_hosts: 
    - "1.1.1.1:2181"
14
27.01.2020, 19:43

Вы можете прочитать файл со строкой замены с помощью подстановки команд оболочки до использования sed . Итак, sed увидит обычную замену:

sed "s / localhost / $ (cat file2) /" file1> changed.txt

6
27.01.2020, 19:43

Теги

Похожие вопросы