当前位置: 首页 > article >正文

OS17.【Linux】进程基础知识(1)

目录1.浅层定义程序和进程的区别2.查看进程的方法ps ajxtop查看/proc目录​编辑PID3.手动用ps查看自己运行的程序在/proc手动查看自己运行的程序目录杀死进程的常用方法进程目录中的文件cwd理解当前路径的含义4.如何管理一个进程程序计数器PC深层理解进程的定义5.Linux下的PCB的简单理解6.练习1.浅层定义浅层定义:进程(process)指的是一个已经加载到内存中的程序(某些情况下,进程也被称为任务(task)),也可以这样说:正在运行的程序叫做进程例如Intel开发手册上的task可以认为是进程:Windows操作系统下可以通过任务管理器来查看进程可以看到:一个操作系统上是运行着多个进程的程序和进程的区别程序是静态的概念,而进程可以理解为浅层定义中的正在运行的程序2.查看进程的方法Linux下可以通过两个命令来查看进程,也可以看一个目录ps ajxps全称是process status,用于查看当前进程的状态a:显示所有用户的进程; j:列出与作业控制相关的信息; x:显示没有控制终端的进程单个选项的内容:合在一起:第一行列出的大写单词的含义在之后的文字会讲top作用:显示Linux进程,实时动态查看系统资源使用情况的命令(类似Windows的任务管理器)当然监控和分析Linux系统性能的工具还有很多,下面给一张图:(来自https://www.brendangregg.com/linuxperf.html网)查看/proc目录proc的全称是processls /procPID会看到许多用数字命名的目录,这个数字其实是每个进程独一无二的PID,非负整数PID是进程唯一标识符,用于对每个进程编号,可以理解为身份证,这样方便操作系统管理手动查看自己进程的目录会在手动用ps查看自己运行的程序下演示3.手动用ps查看自己运行的程序编译以下代码并运行:#include stdio.h int main() { while (1) printf(The process is running...\n); return 0; }使用以下命令查看:ps ajx | head -1 ps ajx | grep test连接两条命令:1. ps ajx | head -1 : 要ps ajx打印结果的第一行2. ps ajx | grep test :使用grep过滤进程执行结果: test.out已经加载到内存中成为了一个进程(两条命令必须成功执行,因此会过滤出grep命令的进程,如果不想显示可以再加上grep -v grep反向过滤)grep命令复习可参见OS6.【Linux】基本指令入门(5)文章在/proc手动查看自己运行的程序目录先运行上方的代码:记住自己进程的PID,这里是23891ls /proc | grep 23891能查到一个目录:下面是23891目录里面的内容:如果用CtrlC杀死进程后,再运行同样的程序,PID是会变动的:杀死进程的常用方法方法1:上方提到的CtrlC方法2:kill命令可以给进程发送9号信号:kill -l用于列出支持的所有信号其中9) SIGKILL是让进程立即终止的信号结论:同一个程序两次运行时PID可能不同进程目录中的文件cwdcwd全称是correctworkdirectory,指当前进程的工作目录(也称工作路径)exeexe全称是execute,指进程正在运行的程序理解当前路径的含义例如touch文件名(不含路径)会在当前路径下创建文件,为什么是当前路径?答:当touch命令运行时,其进程的文件在/proc目录下,其中cwd默认指向当前进程的工作路径又如C语言的fopen()函数,在某些情况下,如果当前路径中没有文件会自动在当前路径下新建文件4.如何管理一个进程一个操作系统上是运行着多个进程的,那就涉及到操作系统是如何管理多个进程的按照之前OS16.【Linux】冯依诺曼体系结构和操作系统的浅层理解文章对管理的定义:管理先描述再组织描述一个进程需要它的属性,例如进程编号、进程状态(是否运行状态?是否阻塞状态......)、优先级等等,将这些属性打包起来形成结构体对象,这个结构体对象称为进程控制块(PCB,全称Process Control Block,进程控制块)注: 上面指的PCB不是印刷电路板(PrintedCircuitBoard)注意:任何一个进程.在加裁到内存形成真正的进程时,操作系统要先创建PCB(图片来自https://www.tutorialspoint.com/operating_system/os_processes.htm)摘一段网上的描述:1Process State(运行状态)The current state of the process i.e., whether it is ready, running, waiting, or whatever.(任务状态、退出代码、退出信号等)2Process privileges(进程优先级),指相对于其他进程的优先级This is required to allow/disallow access to system resources.3Process ID(进程编号)Unique identification(独一无二的标识) for each of the process in the operating system.4Pointer(指针)A pointer to parent process.(其实不仅仅是指向父进程的指针,还包括程序代码和进程相关数据的指针、和其他进程共享的内存块的指针)5Program Counter(程序计数器)Program Counter is a pointer to the address of the next instruction to be executed for this process.6CPU registers(CPU寄存器) (上下文数据)Various CPU registers where process need to be stored for execution for running state.7CPU Scheduling Information(CPU调度信息)Process priority and other scheduling information which is required to schedule the process.8Memory management information(内存管理信息)This includes the information of page table, memory limits, Segment table depending on memory used by the operating system.9Accounting information(记帐信息)This includes the amount of CPU used for process execution, time limits, execution ID etc.(可能包括处理器时间总和、使用的时钟数总和、时间限制、记账号等)10IO status information(IO状态信息)This includes a list of I/O devices allocated to the process.(包括显示的I/O请求、分配给进程的IO设备、被进程使用的文件列表)下面解释几个简单的概念程序计数器PC存储进程即将执行的下一条指令的地址,简单理解为寄存器层面上为16位下为CS:IP,x86架构下的EIP寄存器,x64架构下的RIP寄存器更详细的内容参见王爽老师的《汇编语言》下面摘一段描述:深层理解进程的定义进程内核数据结构对象(PCB,其实还有别的,后面会讲)代码段数据段1.PCB可以形象理解为教务系统中能查到学生信息,而代码段数据段可以形象理解为学生本人2.PCB由操作系统管理,而代码段数据段由程序自行维护3.PCB中还含有相关的指针信息,用于定位代码段数据段,便于操作系统管理讲完了描述,讲讲操作系统组织多个进程的方法:把PCB把结构体串起来,通常使用双向链表struct PCB { //进程的属性(这里省略) struct PCB* next;//指向下一个进程的结构体 struct PCB* prev;//指向上一个进程的结构体 }这样操作系统可以通过对链表的增删查改达到管理多个进程的目的CPU想要执行进程,直接去进程队列去要就行,注意:在排队的是进程的PCB,不是代码段数据段5.Linux下的PCB的简单理解Linux下的PCB是task_struct结构体,其包含进程的各种属性,用于描述进程,task_struct会加载到内存中,下面给出内核源代码:在/include/linux/sched.h下,这里全部给出来,方便查阅:struct task_struct { #ifdef CONFIG_THREAD_INFO_IN_TASK /* * For reasons of header soup (see current_thread_info()), this * must be the first element of task_struct. */ struct thread_info thread_info; #endif unsigned int __state; /* saved state for spinlock sleepers */ unsigned int saved_state; /* * This begins the randomizable portion of task_struct. Only * scheduling-critical items should be added above here. */ randomized_struct_fields_start void *stack; refcount_t usage; /* Per task flags (PF_*), defined further below: */ unsigned int flags; unsigned int ptrace; #ifdef CONFIG_MEM_ALLOC_PROFILING struct alloc_tag *alloc_tag; #endif #ifdef CONFIG_SMP int on_cpu; struct __call_single_node wake_entry; unsigned int wakee_flips; unsigned long wakee_flip_decay_ts; struct task_struct *last_wakee; /* * recent_used_cpu is initially set as the last CPU used by a task * that wakes affine another task. Waker/wakee relationships can * push tasks around a CPU where each wakeup moves to the next one. * Tracking a recently used CPU allows a quick search for a recently * used CPU that may be idle. */ int recent_used_cpu; int wake_cpu; #endif int on_rq; int prio; int static_prio; int normal_prio; unsigned int rt_priority; struct sched_entity se; struct sched_rt_entity rt; struct sched_dl_entity dl; struct sched_dl_entity *dl_server; #ifdef CONFIG_SCHED_CLASS_EXT struct sched_ext_entity scx; #endif const struct sched_class *sched_class; #ifdef CONFIG_SCHED_CORE struct rb_node core_node; unsigned long core_cookie; unsigned int core_occupation; #endif #ifdef CONFIG_CGROUP_SCHED struct task_group *sched_task_group; #endif #ifdef CONFIG_UCLAMP_TASK /* * Clamp values requested for a scheduling entity. * Must be updated with task_rq_lock() held. */ struct uclamp_se uclamp_req[UCLAMP_CNT]; /* * Effective clamp values used for a scheduling entity. * Must be updated with task_rq_lock() held. */ struct uclamp_se uclamp[UCLAMP_CNT]; #endif struct sched_statistics stats; #ifdef CONFIG_PREEMPT_NOTIFIERS /* List of struct preempt_notifier: */ struct hlist_head preempt_notifiers; #endif #ifdef CONFIG_BLK_DEV_IO_TRACE unsigned int btrace_seq; #endif unsigned int policy; unsigned long max_allowed_capacity; int nr_cpus_allowed; const cpumask_t *cpus_ptr; cpumask_t *user_cpus_ptr; cpumask_t cpus_mask; void *migration_pending; #ifdef CONFIG_SMP unsigned short migration_disabled; #endif unsigned short migration_flags; #ifdef CONFIG_PREEMPT_RCU int rcu_read_lock_nesting; union rcu_special rcu_read_unlock_special; struct list_head rcu_node_entry; struct rcu_node *rcu_blocked_node; #endif /* #ifdef CONFIG_PREEMPT_RCU */ #ifdef CONFIG_TASKS_RCU unsigned long rcu_tasks_nvcsw; u8 rcu_tasks_holdout; u8 rcu_tasks_idx; int rcu_tasks_idle_cpu; struct list_head rcu_tasks_holdout_list; int rcu_tasks_exit_cpu; struct list_head rcu_tasks_exit_list; #endif /* #ifdef CONFIG_TASKS_RCU */ #ifdef CONFIG_TASKS_TRACE_RCU int trc_reader_nesting; int trc_ipi_to_cpu; union rcu_special trc_reader_special; struct list_head trc_holdout_list; struct list_head trc_blkd_node; int trc_blkd_cpu; #endif /* #ifdef CONFIG_TASKS_TRACE_RCU */ struct sched_info sched_info; struct list_head tasks; #ifdef CONFIG_SMP struct plist_node pushable_tasks; struct rb_node pushable_dl_tasks; #endif struct mm_struct *mm; struct mm_struct *active_mm; struct address_space *faults_disabled_mapping; int exit_state; int exit_code; int exit_signal; /* The signal sent when the parent dies: */ int pdeath_signal; /* JOBCTL_*, siglock protected: */ unsigned long jobctl; /* Used for emulating ABI behavior of previous Linux versions: */ unsigned int personality; /* Scheduler bits, serialized by scheduler locks: */ unsigned sched_reset_on_fork:1; unsigned sched_contributes_to_load:1; unsigned sched_migrated:1; unsigned sched_task_hot:1; /* Force alignment to the next boundary: */ unsigned :0; /* Unserialized, strictly current */ /* * This field must not be in the scheduler word above due to wakelist * queueing no longer being serialized by p-on_cpu. However: * * p-XXX X; ttwu() * schedule() if (p-on_rq ..) // false * smp_mb__after_spinlock(); if (smp_load_acquire(p-on_cpu) //true * deactivate_task() ttwu_queue_wakelist()) * p-on_rq 0; p-sched_remote_wakeup Y; * * guarantees all stores of current are visible before * -sched_remote_wakeup gets used, so it can be in this word. */ unsigned sched_remote_wakeup:1; #ifdef CONFIG_RT_MUTEXES unsigned sched_rt_mutex:1; #endif /* Bit to tell TOMOYO were in execve(): */ unsigned in_execve:1; unsigned in_iowait:1; #ifndef TIF_RESTORE_SIGMASK unsigned restore_sigmask:1; #endif #ifdef CONFIG_MEMCG_V1 unsigned in_user_fault:1; #endif #ifdef CONFIG_LRU_GEN /* whether the LRU algorithm may apply to this access */ unsigned in_lru_fault:1; #endif #ifdef CONFIG_COMPAT_BRK unsigned brk_randomized:1; #endif #ifdef CONFIG_CGROUPS /* disallow userland-initiated cgroup migration */ unsigned no_cgroup_migration:1; /* task is frozen/stopped (used by the cgroup freezer) */ unsigned frozen:1; #endif #ifdef CONFIG_BLK_CGROUP unsigned use_memdelay:1; #endif #ifdef CONFIG_PSI /* Stalled due to lack of memory */ unsigned in_memstall:1; #endif #ifdef CONFIG_PAGE_OWNER /* Used by page_owneron to detect recursion in page tracking. */ unsigned in_page_owner:1; #endif #ifdef CONFIG_EVENTFD /* Recursion prevention for eventfd_signal() */ unsigned in_eventfd:1; #endif #ifdef CONFIG_ARCH_HAS_CPU_PASID unsigned pasid_activated:1; #endif #ifdef CONFIG_X86_BUS_LOCK_DETECT unsigned reported_split_lock:1; #endif #ifdef CONFIG_TASK_DELAY_ACCT /* delay due to memory thrashing */ unsigned in_thrashing:1; #endif unsigned in_nf_duplicate:1; #ifdef CONFIG_PREEMPT_RT struct netdev_xmit net_xmit; #endif unsigned long atomic_flags; /* Flags requiring atomic access. */ struct restart_block restart_block; pid_t pid; pid_t tgid; #ifdef CONFIG_STACKPROTECTOR /* Canary value for the -fstack-protector GCC feature: */ unsigned long stack_canary; #endif /* * Pointers to the (original) parent process, youngest child, younger sibling, * older sibling, respectively. (p-father can be replaced with * p-real_parent-pid) */ /* Real parent process: */ struct task_struct __rcu *real_parent; /* Recipient of SIGCHLD, wait4() reports: */ struct task_struct __rcu *parent; /* * Children/sibling form the list of natural children: */ struct list_head children; struct list_head sibling; struct task_struct *group_leader; /* * ptraced is the list of tasks this task is using ptrace() on. * * This includes both natural children and PTRACE_ATTACH targets. * ptrace_entry is this tasks link on the p-parent-ptraced list. */ struct list_head ptraced; struct list_head ptrace_entry; /* PID/PID hash table linkage. */ struct pid *thread_pid; struct hlist_node pid_links[PIDTYPE_MAX]; struct list_head thread_node; struct completion *vfork_done; /* CLONE_CHILD_SETTID: */ int __user *set_child_tid; /* CLONE_CHILD_CLEARTID: */ int __user *clear_child_tid; /* PF_KTHREAD | PF_IO_WORKER */ void *worker_private; u64 utime; u64 stime; #ifdef CONFIG_ARCH_HAS_SCALED_CPUTIME u64 utimescaled; u64 stimescaled; #endif u64 gtime; struct prev_cputime prev_cputime; #ifdef CONFIG_VIRT_CPU_ACCOUNTING_GEN struct vtime vtime; #endif #ifdef CONFIG_NO_HZ_FULL atomic_t tick_dep_mask; #endif /* Context switch counts: */ unsigned long nvcsw; unsigned long nivcsw; /* Monotonic time in nsecs: */ u64 start_time; /* Boot based time in nsecs: */ u64 start_boottime; /* MM fault and swap info: this can arguably be seen as either mm-specific or thread-specific: */ unsigned long min_flt; unsigned long maj_flt; /* Empty if CONFIG_POSIX_CPUTIMERSn */ struct posix_cputimers posix_cputimers; #ifdef CONFIG_POSIX_CPU_TIMERS_TASK_WORK struct posix_cputimers_work posix_cputimers_work; #endif /* Process credentials: */ /* Tracers credentials at attach: */ const struct cred __rcu *ptracer_cred; /* Objective and real subjective task credentials (COW): */ const struct cred __rcu *real_cred; /* Effective (overridable) subjective task credentials (COW): */ const struct cred __rcu *cred; #ifdef CONFIG_KEYS /* Cached requested key. */ struct key *cached_requested_key; #endif /* * executable name, excluding path. * * - normally initialized begin_new_exec() * - set it with set_task_comm() * - strscpy_pad() to ensure it is always NUL-terminated and * zero-padded * - task_lock() to ensure the operation is atomic and the name is * fully updated. */ char comm[TASK_COMM_LEN]; struct nameidata *nameidata; #ifdef CONFIG_SYSVIPC struct sysv_sem sysvsem; struct sysv_shm sysvshm; #endif #ifdef CONFIG_DETECT_HUNG_TASK unsigned long last_switch_count; unsigned long last_switch_time; #endif /* Filesystem information: */ struct fs_struct *fs; /* Open file information: */ struct files_struct *files; #ifdef CONFIG_IO_URING struct io_uring_task *io_uring; #endif /* Namespaces: */ struct nsproxy *nsproxy; /* Signal handlers: */ struct signal_struct *signal; struct sighand_struct __rcu *sighand; sigset_t blocked; sigset_t real_blocked; /* Restored if set_restore_sigmask() was used: */ sigset_t saved_sigmask; struct sigpending pending; unsigned long sas_ss_sp; size_t sas_ss_size; unsigned int sas_ss_flags; struct callback_head *task_works; #ifdef CONFIG_AUDIT #ifdef CONFIG_AUDITSYSCALL struct audit_context *audit_context; #endif kuid_t loginuid; unsigned int sessionid; #endif struct seccomp seccomp; struct syscall_user_dispatch syscall_dispatch; /* Thread group tracking: */ u64 parent_exec_id; u64 self_exec_id; /* Protection against (de-)allocation: mm, files, fs, tty, keyrings, mems_allowed, mempolicy: */ spinlock_t alloc_lock; /* Protection of the PI data structures: */ raw_spinlock_t pi_lock; struct wake_q_node wake_q; #ifdef CONFIG_RT_MUTEXES /* PI waiters blocked on a rt_mutex held by this task: */ struct rb_root_cached pi_waiters; /* Updated under owners pi_lock and rq lock */ struct task_struct *pi_top_task; /* Deadlock detection and priority inheritance handling: */ struct rt_mutex_waiter *pi_blocked_on; #endif #ifdef CONFIG_DEBUG_MUTEXES /* Mutex deadlock detection: */ struct mutex_waiter *blocked_on; #endif #ifdef CONFIG_DETECT_HUNG_TASK_BLOCKER /* * Encoded lock address causing task block (lower 2 bits type from * linux/hung_task.h). Accessed via hung_task_*() helpers. */ unsigned long blocker; #endif #ifdef CONFIG_DEBUG_ATOMIC_SLEEP int non_block_count; #endif #ifdef CONFIG_TRACE_IRQFLAGS struct irqtrace_events irqtrace; unsigned int hardirq_threaded; u64 hardirq_chain_key; int softirqs_enabled; int softirq_context; int irq_config; #endif #ifdef CONFIG_PREEMPT_RT int softirq_disable_cnt; #endif #ifdef CONFIG_LOCKDEP # define MAX_LOCK_DEPTH 48UL u64 curr_chain_key; int lockdep_depth; unsigned int lockdep_recursion; struct held_lock held_locks[MAX_LOCK_DEPTH]; #endif #if defined(CONFIG_UBSAN) !defined(CONFIG_UBSAN_TRAP) unsigned int in_ubsan; #endif /* Journalling filesystem info: */ void *journal_info; /* Stacked block device info: */ struct bio_list *bio_list; /* Stack plugging: */ struct blk_plug *plug; /* VM state: */ struct reclaim_state *reclaim_state; struct io_context *io_context; #ifdef CONFIG_COMPACTION struct capture_control *capture_control; #endif /* Ptrace state: */ unsigned long ptrace_message; kernel_siginfo_t *last_siginfo; struct task_io_accounting ioac; #ifdef CONFIG_PSI /* Pressure stall state */ unsigned int psi_flags; #endif #ifdef CONFIG_TASK_XACCT /* Accumulated RSS usage: */ u64 acct_rss_mem1; /* Accumulated virtual memory usage: */ u64 acct_vm_mem1; /* stime utime since last update: */ u64 acct_timexpd; #endif #ifdef CONFIG_CPUSETS /* Protected by -alloc_lock: */ nodemask_t mems_allowed; /* Sequence number to catch updates: */ seqcount_spinlock_t mems_allowed_seq; int cpuset_mem_spread_rotor; #endif #ifdef CONFIG_CGROUPS /* Control Group info protected by css_set_lock: */ struct css_set __rcu *cgroups; /* cg_list protected by css_set_lock and tsk-alloc_lock: */ struct list_head cg_list; #endif #ifdef CONFIG_X86_CPU_RESCTRL u32 closid; u32 rmid; #endif #ifdef CONFIG_FUTEX struct robust_list_head __user *robust_list; #ifdef CONFIG_COMPAT struct compat_robust_list_head __user *compat_robust_list; #endif struct list_head pi_state_list; struct futex_pi_state *pi_state_cache; struct mutex futex_exit_mutex; unsigned int futex_state; #endif #ifdef CONFIG_PERF_EVENTS u8 perf_recursion[PERF_NR_CONTEXTS]; struct perf_event_context *perf_event_ctxp; struct mutex perf_event_mutex; struct list_head perf_event_list; struct perf_ctx_data __rcu *perf_ctx_data; #endif #ifdef CONFIG_DEBUG_PREEMPT unsigned long preempt_disable_ip; #endif #ifdef CONFIG_NUMA /* Protected by alloc_lock: */ struct mempolicy *mempolicy; short il_prev; u8 il_weight; short pref_node_fork; #endif #ifdef CONFIG_NUMA_BALANCING int numa_scan_seq; unsigned int numa_scan_period; unsigned int numa_scan_period_max; int numa_preferred_nid; unsigned long numa_migrate_retry; /* Migration stamp: */ u64 node_stamp; u64 last_task_numa_placement; u64 last_sum_exec_runtime; struct callback_head numa_work; /* * This pointer is only modified for current in syscall and * pagefault context (and for tasks being destroyed), so it can be read * from any of the following contexts: * - RCU read-side critical section * - current-numa_group from everywhere * - tasks runqueue locked, task not running */ struct numa_group __rcu *numa_group; /* * numa_faults is an array split into four regions: * faults_memory, faults_cpu, faults_memory_buffer, faults_cpu_buffer * in this precise order. * * faults_memory: Exponential decaying average of faults on a per-node * basis. Scheduling placement decisions are made based on these * counts. The values remain static for the duration of a PTE scan. * faults_cpu: Track the nodes the process was running on when a NUMA * hinting fault was incurred. * faults_memory_buffer and faults_cpu_buffer: Record faults per node * during the current scan window. When the scan completes, the counts * in faults_memory and faults_cpu decay and these values are copied. */ unsigned long *numa_faults; unsigned long total_numa_faults; /* * numa_faults_locality tracks if faults recorded during the last * scan window were remote/local or failed to migrate. The task scan * period is adapted based on the locality of the faults with different * weights depending on whether they were shared or private faults */ unsigned long numa_faults_locality[3]; unsigned long numa_pages_migrated; #endif /* CONFIG_NUMA_BALANCING */ #ifdef CONFIG_RSEQ struct rseq __user *rseq; u32 rseq_len; u32 rseq_sig; /* * RmW on rseq_event_mask must be performed atomically * with respect to preemption. */ unsigned long rseq_event_mask; # ifdef CONFIG_DEBUG_RSEQ /* * This is a place holder to save a copy of the rseq fields for * validation of read-only fields. The struct rseq has a * variable-length array at the end, so it cannot be used * directly. Reserve a size large enough for the known fields. */ char rseq_fields[sizeof(struct rseq)]; # endif #endif #ifdef CONFIG_SCHED_MM_CID int mm_cid; /* Current cid in mm */ int last_mm_cid; /* Most recent cid in mm */ int migrate_from_cpu; int mm_cid_active; /* Whether cid bitmap is active */ struct callback_head cid_work; #endif struct tlbflush_unmap_batch tlb_ubc; /* Cache last used pipe for splice(): */ struct pipe_inode_info *splice_pipe; struct page_frag task_frag; #ifdef CONFIG_TASK_DELAY_ACCT struct task_delay_info *delays; #endif #ifdef CONFIG_FAULT_INJECTION int make_it_fail; unsigned int fail_nth; #endif /* * When (nr_dirtied nr_dirtied_pause), its time to call * balance_dirty_pages() for a dirty throttling pause: */ int nr_dirtied; int nr_dirtied_pause; /* Start of a write-and-pause period: */ unsigned long dirty_paused_when; #ifdef CONFIG_LATENCYTOP int latency_record_count; struct latency_record latency_record[LT_SAVECOUNT]; #endif /* * Time slack values; these are used to round up poll() and * select() etc timeout values. These are in nanoseconds. */ u64 timer_slack_ns; u64 default_timer_slack_ns; #if defined(CONFIG_KASAN_GENERIC) || defined(CONFIG_KASAN_SW_TAGS) unsigned int kasan_depth; #endif #ifdef CONFIG_KCSAN struct kcsan_ctx kcsan_ctx; #ifdef CONFIG_TRACE_IRQFLAGS struct irqtrace_events kcsan_save_irqtrace; #endif #ifdef CONFIG_KCSAN_WEAK_MEMORY int kcsan_stack_depth; #endif #endif #ifdef CONFIG_KMSAN struct kmsan_ctx kmsan_ctx; #endif #if IS_ENABLED(CONFIG_KUNIT) struct kunit *kunit_test; #endif #ifdef CONFIG_FUNCTION_GRAPH_TRACER /* Index of current stored address in ret_stack: */ int curr_ret_stack; int curr_ret_depth; /* Stack of return addresses for return function tracing: */ unsigned long *ret_stack; /* Timestamp for last schedule: */ unsigned long long ftrace_timestamp; unsigned long long ftrace_sleeptime; /* * Number of functions that havent been traced * because of depth overrun: */ atomic_t trace_overrun; /* Pause tracing: */ atomic_t tracing_graph_pause; #endif #ifdef CONFIG_TRACING /* Bitmask and counter of trace recursion: */ unsigned long trace_recursion; #endif /* CONFIG_TRACING */ #ifdef CONFIG_KCOV /* See kernel/kcov.c for more details. */ /* Coverage collection mode enabled for this task (0 if disabled): */ unsigned int kcov_mode; /* Size of the kcov_area: */ unsigned int kcov_size; /* Buffer for coverage collection: */ void *kcov_area; /* KCOV descriptor wired with this task or NULL: */ struct kcov *kcov; /* KCOV common handle for remote coverage collection: */ u64 kcov_handle; /* KCOV sequence number: */ int kcov_sequence; /* Collect coverage from softirq context: */ unsigned int kcov_softirq; #endif #ifdef CONFIG_MEMCG_V1 struct mem_cgroup *memcg_in_oom; #endif #ifdef CONFIG_MEMCG /* Number of pages to reclaim on returning to userland: */ unsigned int memcg_nr_pages_over_high; /* Used by memcontrol for targeted memcg charge: */ struct mem_cgroup *active_memcg; /* Cache for current-cgroups-memcg-objcg lookups: */ struct obj_cgroup *objcg; #endif #ifdef CONFIG_BLK_CGROUP struct gendisk *throttle_disk; #endif #ifdef CONFIG_UPROBES struct uprobe_task *utask; #endif #if defined(CONFIG_BCACHE) || defined(CONFIG_BCACHE_MODULE) unsigned int sequential_io; unsigned int sequential_io_avg; #endif struct kmap_ctrl kmap_ctrl; #ifdef CONFIG_DEBUG_ATOMIC_SLEEP unsigned long task_state_change; # ifdef CONFIG_PREEMPT_RT unsigned long saved_state_change; # endif #endif struct rcu_head rcu; refcount_t rcu_users; int pagefault_disabled; #ifdef CONFIG_MMU struct task_struct *oom_reaper_list; struct timer_list oom_reaper_timer; #endif #ifdef CONFIG_VMAP_STACK struct vm_struct *stack_vm_area; #endif #ifdef CONFIG_THREAD_INFO_IN_TASK /* A live task holds one reference: */ refcount_t stack_refcount; #endif #ifdef CONFIG_LIVEPATCH int patch_state; #endif #ifdef CONFIG_SECURITY /* Used by LSM modules for access restriction: */ void *security; #endif #ifdef CONFIG_BPF_SYSCALL /* Used by BPF task local storage */ struct bpf_local_storage __rcu *bpf_storage; /* Used for BPF run context */ struct bpf_run_ctx *bpf_ctx; #endif /* Used by BPF for per-TASK xdp storage */ struct bpf_net_context *bpf_net_context; #ifdef CONFIG_GCC_PLUGIN_STACKLEAK unsigned long lowest_stack; unsigned long prev_lowest_stack; #endif #ifdef CONFIG_X86_MCE void __user *mce_vaddr; __u64 mce_kflags; u64 mce_addr; __u64 mce_ripv : 1, mce_whole_page : 1, __mce_reserved : 62; struct callback_head mce_kill_me; int mce_count; #endif #ifdef CONFIG_KRETPROBES struct llist_head kretprobe_instances; #endif #ifdef CONFIG_RETHOOK struct llist_head rethooks; #endif #ifdef CONFIG_ARCH_HAS_PARANOID_L1D_FLUSH /* * If L1D flush is supported on mm context switch * then we use this callback head to queue kill work * to kill tasks that are not running on SMT disabled * cores */ struct callback_head l1d_flush_kill; #endif #ifdef CONFIG_RV /* * Per-task RV monitor. Nowadays fixed in RV_PER_TASK_MONITORS. * If we find justification for more monitors, we can think * about adding more or developing a dynamic method. So far, * none of these are justified. */ union rv_task_monitor rv[RV_PER_TASK_MONITORS]; #endif #ifdef CONFIG_USER_EVENTS struct user_event_mm *user_event_mm; #endif /* CPU-specific state of this task: */ struct thread_struct thread; /* * New fields for task_struct should be added above here, so that * they are included in the randomized portion of task_struct. */ randomized_struct_fields_end } __attribute__ ((aligned (64)));6.练习下列有关进程的说法中错误的是? [多选]A.进程与程序是一一对应的B.进程与作业是一一对应的C.进程是静态的D.进程是动态的过程答:作业是用户需要计算机完成的某项任务,是要求计算机所做工作的集合,不是进程以下摘自《 计算机操作系统慕课版》作业是一个比程序更为广泛的概念它不仅包含了通常的程序和数据而且配有一份作业处理机调度说明书系统根据该说明书对程序的运行进行控制。在多道批处理系统中会将作业作为基本单位从外存调入内存。所以选ABC下一篇文章将继续讲解进程的基础知识

相关文章:

OS17.【Linux】进程基础知识(1)

目录 1.浅层定义 程序和进程的区别 2.查看进程的方法 ps ajx top 查看/proc目录 ​编辑 PID 3.手动用ps查看自己运行的程序 在/proc手动查看自己运行的程序目录 杀死进程的常用方法 进程目录中的文件 cwd 理解"当前路径"的含义 4.如何管理一个进程 程…...

深入解析Spring AI与MilvusVectorStore的集成实践

1. Spring AI与MilvusVectorStore集成概述 当我们需要处理海量非结构化数据时,传统数据库往往力不从心。想象一下你有一个装满各种文档的仓库,每次查找相关内容都需要人工翻阅——这正是向量数据库要解决的问题。Spring AI与Milvus的集成就像给这个仓库配…...

MoveCertificate终极指南:Android 7-15系统证书管理全解析

MoveCertificate终极指南:Android 7-15系统证书管理全解析 【免费下载链接】MoveCertificate 支持Android7-15移动证书,兼容magiskv20.4/kernelsu/APatch, Support Android7-15, compatible with magiskv20.4/kernelsu/APatch 项目地址: https://gitco…...

AgiBot World数据集实战:如何用百万级轨迹训练你的机器人策略(附避坑指南)

AgiBot World数据集实战:百万级轨迹训练机器人策略的完整指南 1. 数据集的革命性价值 在机器人学习领域,数据质量与规模直接决定了策略模型的性能上限。AgiBot World作为当前最大的开源机器人操作数据集,其核心突破在于: 规模突…...

Shell脚本一键部署Kubenetes(k8s)前置环境

1. 服务器环境[rootlocalhost~]# cat /etc/redhat-release CentOS Linux release 7.9.2009 (Core)2. 脚本内容#!/bin/bash#本文针对CentOS7系统#1)关闭交换分区swap disable_swap(){echo -e "\e[32m1)开始关闭swap\e[0m"#备份fstabsudo cp /e…...

如何让键盘听懂你的设备语言?设备条件判断打造智能多设备键盘映射方案

如何让键盘听懂你的设备语言?设备条件判断打造智能多设备键盘映射方案 【免费下载链接】Karabiner-Elements Karabiner-Elements is a powerful utility for keyboard customization on macOS Sierra (10.12) or later. 项目地址: https://gitcode.com/gh_mirrors…...

Termux:X11的10个核心功能解析:触摸手势、键盘切换与多显示器支持

Termux:X11的10个核心功能解析:触摸手势、键盘切换与多显示器支持 【免费下载链接】termux-x11 Termux X11 add-on application. Still in early development. 项目地址: https://gitcode.com/gh_mirrors/te/termux-x11 Termux:X11是一个专为Android设备优化…...

# 发散创新:基于 Rust的分布式数据库架构设计与实战演练在当前云原生和微服务架

发散创新:基于 Rust 的分布式数据库架构设计与实战演练 在当前云原生和微服务架构盛行的背景下,分布式数据库已成为高并发、高可用系统的核心基础设施。本文将深入探讨如何使用 Rust 编程语言构建一个轻量级但功能完整的分布式数据库原型,重点…...

SolidWorks装配体设计必备:如何用草图投影实现零件快速匹配(2023最新版)

SolidWorks装配体设计效率革命:草图投影的进阶应用与实战技巧 在三维机械设计领域,装配体设计往往是最考验工程师功底的环节。当数十甚至上百个零件需要在虚拟空间中精确配合时,传统逐个修改零件的方法不仅效率低下,还容易产生累积…...

Flax过滤器系统终极指南:如何实现灵活的变量选择机制

Flax过滤器系统终极指南:如何实现灵活的变量选择机制 【免费下载链接】flax Flax is a neural network library for JAX that is designed for flexibility. 项目地址: https://gitcode.com/GitHub_Trending/fl/flax Flax NNX的过滤器系统是神经网络编程中的…...

VLP-16数据包解析实战:从原始字节到三维点云

1. VLP-16数据包解析入门指南 第一次拿到VLP-16激光雷达的原始UDP数据流时,我完全被那一串串十六进制数字搞懵了。这就像收到一封用密码写成的信,明明知道里面藏着宝贵的三维环境信息,却不知道如何破译。经过几个项目的实战积累,我…...

从国赛真题到实战演练:蓝桥杯CTF网络安全竞赛核心题型深度剖析

1. 逆向工程实战:从加密程序到Flag还原 去年蓝桥杯CTF国赛的第一道逆向题让不少选手印象深刻。题目给出一个名为encodefile的可执行程序和一个加密后的数据文件enc.dat,要求还原原始flag内容。这类题型在CTF中非常典型,主要考察选手对程序逻辑…...

IEC102协议报文解析:从格式到传输的实战指南

1. IEC102协议基础入门:电力系统的"语言密码" 第一次接触IEC102协议时,我完全被那些十六进制代码和术语搞晕了。直到有一次在变电站调试电表,看到主站和终端设备用这种"暗号"流畅对话,才真正理解它的价值。简…...

从文档智能处理到自动化工作流:现代开发技能的全栈实践

从文档智能处理到自动化工作流:现代开发技能的全栈实践 【免费下载链接】skills 本仓库包含的技能展示了Claude技能系统的潜力。这些技能涵盖从创意应用到技术任务、再到企业工作流。 项目地址: https://gitcode.com/GitHub_Trending/skills3/skills 在日常开…...

终极指南:如何利用Reor AI智能笔记应用的本地化语义搜索与智能推荐功能

终极指南:如何利用Reor AI智能笔记应用的本地化语义搜索与智能推荐功能 【免费下载链接】reor Self-organizing AI note-taking app that runs models locally. 项目地址: https://gitcode.com/GitHub_Trending/re/reor Reor是一款革命性的AI智能笔记应用&am…...

热量表(热能表)完整指南:原理、公式推导、STM32 嵌入式软件全实现

目录 一、热量表工作原理 1. 核心物理原理 2. 系统组成 3. 工作流程 二、热量计算公式(国标 / 欧标 EN1434)完整推导 1. 基础定义 2. 最终标准热量公式(工业直接用) 瞬时热量: 累积热量: 3. 公式…...

当柔性车间遇上强化学习:从传统规则到DRL的调度进化史

柔性车间调度的智能革命:深度强化学习如何重塑制造业决策 在当今快节奏、定制化需求激增的制造业环境中,传统的生产调度方法正面临前所未有的挑战。想象一下,一个典型的电子设备制造车间:数百种不同规格的订单不断涌入&#xff0c…...

Java JFreeChart 折线图X轴标签优化:5分钟搞定密集数据展示问题

Java JFreeChart折线图X轴标签优化实战:解决密集数据展示难题 在数据可视化领域,折线图是最常用的图表类型之一。但当数据量激增时,X轴标签往往会因为空间不足而显示为省略号,严重影响图表可读性。本文将深入探讨如何通过定制化方…...

颠覆式开源工具OptiScaler:全平台显卡优化解决方案

颠覆式开源工具OptiScaler:全平台显卡优化解决方案 【免费下载链接】OptiScaler DLSS replacement for AMD/Intel/Nvidia cards with multiple upscalers (XeSS/FSR2/DLSS) 项目地址: https://gitcode.com/GitHub_Trending/op/OptiScaler 你的显卡真的被充分…...

别再手动测PLC了!用C# + Modbus Poll/Slave + VSPD三件套,5分钟搞定ModbusRTU通信仿真

工业自动化开发者的效率革命:C#与Modbus仿真工具链实战指南 在工业自动化领域,时间就是金钱。传统PLC调试过程中,工程师常常需要反复连接真实硬件设备,忍受着物理线路故障、设备资源占用和不可复现的测试环境等问题。这种低效的工…...

零基础玩转CosyVoice:3步完成声音克隆,制作专属语音祝福

零基础玩转CosyVoice:3步完成声音克隆,制作专属语音祝福 1. 引言:让声音成为你的专属礼物 你有没有想过,用自己或亲友的声音,生成一段独一无二的语音祝福?比如,用妈妈的声音说“生日快乐”&am…...

技术赋能B端拓客:号码核验行业的革新与实践,氪迹科技法人号码核验系统,阶梯式价格

2026年,随着B端市场竞争的持续加剧,“精准获客、降本增效”已从行业口号转变为企业生存发展的核心诉求,号码核验作为B端拓客全流程的前置关键环节,其服务质量直接决定了拓客效率、人力效能与投入回报比,成为影响企业拓…...

技术赋能B端拓客:号码核验行业的破局与价值重塑,氪迹科技法人股东号码筛选系统,阶梯式价格

2026年,B端拓客正式迈入智能内卷时代,“精准获客、降本增效”成为企业突破业绩瓶颈的核心关键词,而号码核验作为拓客流程的前置过滤环节,直接决定了线索质量与人力效能,成为影响拓客投入回报比的关键变量。当前&#x…...

从零开始:crAPI靶场环境搭建与实战通关指南

1. 环境准备:从零搭建crAPI靶场 第一次接触crAPI靶场时,我花了两小时才搞明白为什么docker-compose总是报错。后来发现是因为Ubuntu系统残留的旧版Docker没卸载干净。建议所有新手都从干净的Ubuntu 20.04 LTS环境开始,这会帮你避开80%的环境问…...

51:L构建容器与Kubernetes安全:蓝队的容器防御

作者: HOS(安全风信子) 日期: 2026-03-19 主要来源平台: GitHub 摘要: 当基拉开始攻击容器与Kubernetes环境时,传统的安全防御方法已无法满足需求。L开发容器与Kubernetes安全防御系统,保护容器环境的安全。…...

Labelme标注效率翻倍!手把手教你修改源码,让标签信息直接显示在图上(支持Ctrl+T切换)

Labelme标注效率翻倍实战:源码修改实现标签可视化与快捷键切换 在计算机视觉项目的标注环节中,Labelme作为开源标注工具被广泛使用。但实际标注过程中,我们常常遇到一个令人抓狂的问题:当需要检查某个标注框的具体信息时&#xff…...

深入RISC-V调试模块:从硬件设计视角看DM、DTM与抽象命令的实现

RISC-V调试模块硬件架构深度解析:从状态机到抽象命令的工程实现 1. RISC-V调试系统的硬件架构全景 在RISC-V生态系统中,调试模块(Debug Module, DM)作为连接外部调试器与处理器核心的关键枢纽,其硬件设计直接决定了芯片的可调试性。与传统的…...

AI专著写作指南:深度剖析热门工具,助你专著创作一步到位

撰写学术专著的挑战与AI解决方案 撰写学术专著是一项严峻的挑战,它不仅考验着研究者的学术能力,还对心理承受能力提出了很高的要求。与论文写作常常可以依赖团队的支持不同,专著的创作更多的是独立作战。从选题到框架设计,再到细…...

获取应用内部JMX统计信息的编程方法

本文介绍了如何在Java应用程序中编程JMX(Java Management Extensions)统计信息,无需建立远程连接或使用外部JMX客户端。通过直接访问MBeanServer,您可以查询和获取应用程序中的各种性能指标和管理信息,如Kafka消费者组…...

终极指南:如何用Docker快速部署opencommit AI提交工具

终极指南:如何用Docker快速部署opencommit AI提交工具 【免费下载链接】opencommit Auto-generate impressive commits with AI in 1 second 🤯🔫 项目地址: https://gitcode.com/gh_mirrors/op/opencommit opencommit是一款AI驱动的提…...