Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Principles of computer and operating system

2025-04-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

Principles of computer and operating system:

OS

32bit, 64bit, 2 ^ 32 = 4G 2 ^ 64 almost infinity

CPU line multiplexing

PAE:Physical Address Extension physical address extension

32bit.jobber 4bit = 64g

The program has locality and replacement strategy.

Spatial locality, temporal locality

CPU has multi-level cache static RAM

N-way association

Cache microcosm

The more the number of roads, the greater the hit rate.

Step by step replacement

CPU only deals with first-level cache

Write through general writing

Write Back writeback data is written to main memory when it is lost

Video card Video Card needs to interact directly with CPU

PCI-E SSD M2

IO Port one-piece continuous port bus multiplexing

Poll mechanism notification mechanism

Interrupt controller Interrupt Controller

A place where competition is likely to occur in critical areas.

DMA: direct memory access

OS:VM

CPU:

Time, slicing

Cache, cache current program data

Process switching: save the site, restore the site

Memory separation

4K page, page frame (page frame)

Instruction, data, stack, stack

Process description structure

Linear address virtual address page directory

Physical address

Directory is a mapping relationship.

Memory, and the memory protection space mapping can be achieved by converting the physical address to a linear address.

The operation of Icano was interrupted.

Kernel-- > process

There are two modes of CPU: user mode and kernel mode

CPU 4-layer ring mode

Simulation and simulation

Process status:

Ready

Sleeping

Interruptible

Uninterruptible

Relationship between process and operating system:

Process descriptor

Process metadata

Bidirectional linked list

Linux supports process preemption

System clock, internal clock frequency tick clock interrupt

Process type:

Interactive process (Ihamo)

Batch process (CPU intensive)

Real-time process (Real-time)

CPU: long time slot, low priority

IO: short time slice and high priority

Linux priority: priority

Real-time priority: 1-99. The smaller the number, the lower the priority.

Static priority: 100-139. The smaller the number, the higher the priority.

-20 019 100,139 nice 0 corresponds to static priority 100

Real-time priority is higher than static priority

Ps-e-o class,rtprio,pri,nice,cmd

Nice value: adjust static priority

There are parentheses to indicate the kernel thread

Scheduling category:

Real-time processes:

SCHED_FIFO First In First out

SCHED_RR Round Robin

SCHED_Other: used to schedule processes between 100and 139s

Dynamic priority:

Dynamic priority = max (100min (static priority-bonus + 5139))

Manually adjust the priority:

100139 nice

Nice N COMMAND

Renice-n # PID

Chrt-p [prio] PID

1-99

Chrt-f-p [prio] PID

Chrt-r-p [prio] PID

139queues in Linux system

Scan queue 99-1100-139 switch between active queue and expired queue

CPQ:Complete Fair Scheduler SCHED_Other after linux2.6

Kernel-- > init

Init fork (): system call

Task_struct

Memory-- > Parent

COW: Copy On Write

RHEL6.4

Tick less has no clock interrupt

Interrupt-driven

Hard interrupt

Soft interrupt

Deep sleep

First-level cache I1 instruction 1dint D1 Data1

SMP symmetric multiprocessor A CPU slot is called a socket

NUMA non-uniform memory access

Numastat command

Numactl command

Numad command

CPU affinity:CPU in-laws relationship

Taskset: bind a process to a CPU

For example:

Taskset-p mask pid

Taskset-p-c 0-2J 7 101 binds 101 processes to cpu0,1,2,7

Interrupts should be bound to non-isolated CPU to avoid those isolated CPU handler interrupts

Echo CPU_MASK > / proc//smp_affinity

Rpm-qf sysstat

Mpstat

Vmstat

Number of sar-w context switches

Taskset-p-c 0 16380

Virtualized environment:

PA-> HA-> MA

Virtual machine conversion: PA- > HA

GuestOS, OS

Shadow PT

Memory:

TLB: improve performanc

Hugetable page

Hugetlbfs file system

Cat / proc/meminfo | grep Hugepages

Sysctl-w vm.nr_hugepages=10 enables large pages

Strace:

Strace COMMAND: view the syscall of a command

Strace-p PID: view the syscall that has started the process

-c: output its general information in

-o FILE: save the trace results to a file for subsequent analysis

Slab

Strategies for using memory

1. Reduce the system overhead of miniature memory objects

Slab

2. Reduce the service time of the slow subsystem

Using buffer cache to cache file metadata

Use page cache to cache DISK IO

Use shm to complete interprocess communication

Use buffer cache, arp cache, and connetion tracking to improve network IO performance

Running out of memory and system crashing

Tuning page allocation

Overuse of physical memory is premised on swap:

More than a portion of physical memory

Swap

Tuning overcommit

Ls / proc/1 oom_score

Slabtop command

Slab cache

ARP cache

Tuning ARP cache

Page cache

Vfs_cache_pressure

0: do not recycle dentries and inodes

1-99: tends not to recycle

100: the tendency is the same as page cache and swap cache

100 percent: tend to recycle

When using swap, the page-cluster virtualization environment will use the

Anonymous pages

Use anonymous pages for interprocess communication

/ proc, / sys

CPU usage, memory usage

Performance metrics, shutting down unnecessary processes

Performance tuning:

Process management, CPU

Memory tuning

I/O

File system

Network subsystem

Tuning ideas:

Performance indicator, locating bottleneck

Comprehensive optimization

System-level tuning tools:

SystemTap

Oprofile

Valgrind

Perf

Interprocess communication management class command

Ipcs-l

Ipcrm

Sharememory

Shmmni: system level, upper limit of shared memory segments allowed to be used

Shmall: system level, the maximum number of pages that can be allocated for shared memory

Shmmax: the upper limit of a single shared memory segment

Message

Msgmnb: the upper limit of a single message queue in bytes

Msgmni: system level, maximum number of message queues

Msgmax: the maximum size of a single message (in bytes)

Adjust according to demand, usually turn it up.

Tuning pdflush

1, periodicity, 2, observation 3, dirty page share

Manually clear the dirty cache and cache

When memory is exhausted

Out-of-memory killer

Oom-adj

-17:disables the oom_killer for that process

-16-15: assist in calculating oom-score

The higher the oom-adj, the higher the oom-score score, the greater the probability of being killed.

How to view memory leaks:

Valgrind-tool=memcheck cat / proc/$$/maps

Several categories of memory subsystem that need to be adjusted

HugePage: TLB

IPC

Pdflush

Slab

Swap

Oom

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report