Notes
main
main
  • Introduction
  • linuxKernel
    • tips
    • make_help
    • old linux
      • compile_linux0.11
      • TestEnvironment
      • load_setup
      • get_hard_data
    • list
    • plist
    • fifo
    • idr
    • xarray
    • rbtree
    • maple_tree
    • syscall
    • bitmap
    • page
    • page_flags
    • page_size
    • page mapcount
    • page refcount
    • folio
    • slub
      • proc_slabinfo
      • slub_theory
      • kmalloc_kfree
      • kmem_cache
      • slab_alloc
      • slab_free
      • proc_meminfo_SReclaimable_SReclaimable
    • vmalloc
    • brk
    • mmap
    • mremap
    • mprotect
    • madvise
    • read
    • write
    • shmem
    • huge_page
    • page_fault
    • rmap
    • lru
    • multi-gen-LRU
    • page_reclaim
    • page_cache
    • page_table
    • rcu
    • kvm
    • aarch64_boot
    • tracing_system
    • cache_coherence_and_memory_consistency
    • cpu_speculates
    • mmap_lock
    • per-vma_lock
    • cgroup
    • symbol
    • campact
    • page_ext
    • mempool
    • kernelstack
    • filesystem
    • io_stack
    • workingset
    • ioremap
    • sched_period
  • linuxDebug
    • openocd_openjtag
    • i2c_tools
    • objdump
    • addr2line
    • gdb_useage
    • debug_linux_kernel_via_gdb
    • debug_linux_module_via_gdb
    • early_boot
    • sequentially_execute
    • dynamic_debug
    • research_linuxKernel_by_patch
    • tracefs
    • ebpf
    • bpftrace
    • perf
    • flame_graph
    • crash
    • ASAN_HWASAN_MTE_check_mem_bug
    • page_owner
    • vmtouch
    • fio
    • benchmark
  • linuxSystem
    • common
      • system_version
      • procfs
      • proc_sys_vm
      • cmd_ps
      • makefile
      • file_descriptor
      • psi
      • ulimit
      • top
      • delay_accounting
    • ubuntu
      • custom_kernel
      • get_cmd_src
      • record_ssh_info
      • log
      • run_custom_script
      • repo
      • cockpit
      • nfs
      • tftp
      • misc
    • fedora
      • system_upgrade
      • custom_kernel
      • lvextend
      • yt-dlp
      • jellyfin
  • linuxDriver
    • i2c_peripherals_driver
    • spi_peripherals_driver
    • gpio_subsystem
    • IRQ_driver
    • blockIO_unblockIO_async
    • linux_own_driver
    • misc_device
    • input_device
    • timer
    • atomic_spinlock_semaphore_mutex
    • lcd
    • touch_screen
    • debugfs
    • v4l2
    • mmap
  • hardware
    • paging_mmu_pt
    • iommu
  • process_thread_scheduler
    • scheduler01
    • scheduler02
    • scheduler03
    • scheduler04
    • scheduler05
    • scheduler06
  • memory_management
    • mm1
    • mm2
    • mm3
    • mm4
    • mm5
  • input_output_filesystem
    • io_fs_01
    • io_fs_02
    • io_fs_03
    • io_fs_04
  • lock_and_lockup_detector
    • general_lock
    • hung_task
    • softLockup_hardLockup
    • crash_experiment
  • MIT_6.S081
    • 6.S081_Operating_System_Engineering
    • Schedule.md
    • Class
      • Overview
      • Administrivia
    • Labs
      • Tools
      • Guidance
      • startup
      • syscall
      • page_table
      • Calling_Convention
      • traps
    • xv6
      • xv6
    • References.md
  • qemu
    • qemu_buildroot
    • qemu_busybox.md
    • Serial.md
    • demo_mini2440
      • 0_compilation_error_summary
      • 1_compilation_steps
      • 2_operation_mode
      • 3_transplant_tools_libraries
      • 4_tools_use
      • reference_website
  • tools
    • getKernelSourceCodeList
    • nat
    • shell
    • translating
    • YouCompleteMe
    • cscope
    • global
    • vscode
    • vim
    • binary
    • markdown
    • draw
    • git
    • tig
    • tmux
    • mail_client
    • download_patchset_from_LKML
    • minicom
    • clash
  • other
    • interview
    • interview_c_base
    • know_dontknow
    • Stop-Ask-Questions-The-Stupid-Ways
    • How-To-Ask-Questions-The-Smart-Way
    • docker
    • buildroot
    • rv32_to_rv64
Powered by GitBook
On this page
  • 简介
  • API 解析
  • 参考

Was this helpful?

  1. linuxKernel

plist

简介

plist,基于优先级排序的双向链表,每一个节点都有一个优先级。

主要结构体,struct plist_head 代表 plist 的头节点, struct plist_node 代表 plist 的普通节点,如下:

struct plist_head {
        struct list_head node_list;
};

struct plist_node {
        int                     prio;      // prio 值越小,优先级越高
        struct list_head        prio_list;
        struct list_head        node_list;
};

假如我们创建 plist,头节点为 head, 4 个普通节点为 node1~node4,其中 node1 的优先级为10, node2 的优先级为20,node3 的优先级为30,node4 的优先级为10, 现在它们的布局如下:

+---------------------------------------------------------------------------+
|                                                                           |
|     head           node1          node2          node4          node3     |
+-> node_list <--> node_list <--> node_list <--> node_list <--> node_list <-+
               +-> prio_list <--> prio_list      prio_list      prio_list <-+
               |                          ^                     ^           |
               |                          |                     |           |
               |                          +---------------------+           |
               +------------------------------------------------------------+

head node_list 链接所有 node,node1 prio_list 链接所有不同优先级的第一个 node。

API 解析

  • PLIST_HEAD() 将头节点进行静态初始化

  • plist_head_init() 将头节点进行动态初始化

  • PLIST_NODE_INIT() 将普通节点进行静态初始化,

  • plist_node_init() 将普通节点进行动态初始化

  • plist_head_empty() 判断头节点是否为空

  • plist_node_empty() 判断普通节点是否为空

以下将 普通节点 简称为 节点

  • plist_first() 返回 plist 的第一个节点,即 优先级最高的节点

  • plist_last() 返回 plist 的最后一个节点,即 优先级最低的节点

  • plist_first_entry() 返回包含第一个节点的结构体

  • plist_last_entry()返回包含最后一个节点的结构体

  • plist_for_each() 从头开始遍历 plist,得到每一个节点

  • plist_for_each_entry() 从头开始遍历 plist,得到每一个包含节点的结构体

  • plist_add() 添加一个节点到 plist 中

  • plist_del() 将一个节点从 plist 中删除

  • plist_requeue() 将一个节点重新加入 plist 中,相当于 优化版本的先删除再加入

参考

include/linux/plist.h

PreviouslistNextfifo

Last updated 1 year ago

Was this helpful?