【Linux】进程描述符

2023-10-27

linux进程管理(1)---进程描述符

进程描述符


Linux使用进程描述符数据结构记录现场信息,然后给予进程描述符管理进程,包括进程的创建、调度、消亡等操作。

进程除了包括运行着的程序,还包括系统资源(当前CPU现场、调度信息、进程间关系等)。记录这些线程信息的数据结构就是进程描述符 task_struct(include/linux/sched.h中)
每个进程都有一个进程描述符,记录以下重要信息:进程标识符、进程当前状态、栈地址空间、内存地址空间、文件系统、打开的文件、信号量等。

获取方式:

在x86体系中,通过SP寄存器可以快速获取当前进程栈的位置;linux在栈的末端存放了一个特殊的数据结构thread_info,thread_info中存放了指向task_struct的指针。根据这个原理,首先当前进程通过SP寄存器获取栈的位置,然后根据栈大小(一般为1-2页)获取thread_info的地址,最后通过thread_info获取当前进程的地址。
linux不仅有进程ID,而且给每个线程也分配了线程ID。对于task_struct数据结构的成员来说,pid是线程ID,tgid是线程的进程ID(该进程也叫线程组长)。

进程状态:

调度程序根据进程状态决定是否调度进程,linux是用概念bitmap(位图)表示进程状态,一共有11种状态;这些状态可以分为三类:运行态、睡眠态、退出态。只有运行态的进程才能被调度程序调度;进程等待某个资源时处于睡眠态(可中断态、不可中断态);进程退出时处于退出态(僵尸态、死亡态)。其他的进程状态还包括停止态、跟踪态等,这些状态处于特定的使用场景中,就不介绍了。

  • 运行态:进程在cpu上运行或者等待运行。
  • 睡眠态:睡眠态分为可中断态和不可中断态。进程因为等待某个资源而处于睡眠状态。这两者的区别是不可中断态忽略发送过来的唤醒信号量,因为这个状态的进程获取了重要的系统资源,因此不能被轻易打断,该状态较少使用。
  • 退出态:退出态分为僵尸态和死亡态。进程完成使命退出后处于僵尸态,此时进程的资源已经被释放,仅仅保留了task_struct结构(父进程可能使用);而死亡态不仅释放了所有资源,并且连task_struct结构也释放了。

系统给每个状态分配了一个字母缩写“RSDTtZXxKWP”,对应关系如下图所示。

#define TASK_RUNNING        0
#define TASK_INTERRUPTIBLE    1
#define TASK_UNINTERRUPTIBLE    2
#define __TASK_STOPPED        4
#define __TASK_TRACED        8
/* in tsk->exit_state */
#define EXIT_ZOMBIE        16
#define EXIT_DEAD        32
/* in tsk->state again */
#define TASK_DEAD        64
#define TASK_WAKEKILL        128
#define TASK_WAKING        256
#define TASK_PARKED        512
#define TASK_STATE_MAX        1024

#define TASK_STATE_TO_CHAR_STR "RSDTtZXxKWP"

进程栈

linux系统为每个用户进程分配了两个栈:用户栈和内核栈。当一个进程在用户空间执行时,系统使用用户栈;当在内核空间执行时,系统使用内核栈。由于内核栈地址空间的限制,内核栈不会分配很大的空间。此外,内核进程只有内核栈,没有用户栈。
当进程从用户空间陷入到内核空间时,首先,操作系统在内核栈中记录用户栈的当前位置,然后将栈寄存器指向内核栈;内核空间的程序执行完毕后,操作系统根据内核栈中记录的用户栈位置,重新将栈寄存器指向用户栈。由于每次从内核空间中返回时,内核栈肯定已经使用完毕,所以从用户栈切换到内核栈时,只需要简单的将栈寄存器指向内核栈顶即可。

linux进程管理(1)---进程描述符 https://blog.csdn.net/luomoweilan/article/details/21196093


为了进程管理,内核必须对每个进程所做的事情进行清楚的描述。比如内核需要知道进程的优先级,进程当前的状态,在挂起和恢复进程的时候,需要对进程进行相应的操作。进程描述符还描述了进程使用的地址空间,访问的文件等等,这些都是进程描述符的作用。包括了很多进程属性的字段,还有一些字段包括了指向其他数据结构的指针,如下图:

  • TASK_RUNNING: 要么在CPU上执行,要么准备执行。
  • TASK_INTERRUPTIBLE: 进程被挂起(睡眠),直到某个为真的条件触发,产生一个硬件中断,释放进程正等待的系统资源,或传递一个信号都可以唤醒进程。
  • TASK_UNINTERRUPTIBLE: 不可中断的等待状态,与把信号传递给睡眠进程不能改变它的状态1
  • TASK_STOPPED: 进程的执行被暂停,当收到SIGSTOP、SIGTSTP、SIGTTIN或SIGTTOU信号后,进入暂停状态。
  • TASK_TRACED: 跟踪状态,进程的执行由debugger程序暂停。
  • TASK_ZOMBIE: 进程执行被终止,但是父进程还没有发布wait4或waitpid系统调用返回有关死亡进程的信息。
  • TASK_DEAD: 僵死撤销状态。

task_struct 结构体:

<include/linux/sched.h>

struct task_struct {
  // -1表示不可运行,0表示可运行,大于0表示停止
  volatile long state;
  void *stack;
  atomic_t usage;
  // 每进程标志,上下文定义
  unsigned int flags;
  unsigned int ptrace;

  // 大内核锁的深度
  int lock_depth;

#ifdef CONFIG_SMP
#ifdef __ARCH_WANT_UNLOCKED_CTXSW
  int oncpu;
#endif
#endif
  // 优先级
  int prio, static_prio, normal_prio;
  unsigned int rt_priority;
  const struct sched_class *sched_class;
  struct sched_entity se;
  struct sched_rt_entity rt;

#ifdef CONFIG_PREEMPT_NOTIFIERS
  /* 同步的通知者 */
  struct hlist_head preempt_notifiers;
#endif
  unsigned char fpu_counter;
#ifdef CONFIG_BLK_DEV_IO_TRACE
  unsigned int btrace_seq;
#endif

  unsigned int policy;
  cpumask_t cpus_allowed;

#ifdef CONFIG_TREE_PREEMPT_RCU
  int rcu_read_lock_nesting;
  char rcu_read_unlock_special;
  struct rcu_node *rcu_blocked_node;
  struct list_head rcu_node_entry;
#endif

#if defined(CONFIG_SCHEDSTATS) \
  || defined(CONFIG_TASK_DELAY_ACCT)
  struct sched_info sched_info;
#endif

  struct list_head tasks;
  struct plist_node pushable_tasks;

  struct mm_struct *mm, *active_mm;

/* 进程状态 */
  int exit_state;
  int exit_code, exit_signal;
  // 在父进程终止时发送的信号
  int pdeath_signal;

  unsigned int personality;
  unsigned did_exec:1;
  unsigned in_execve:1;
  unsigned in_iowait:1;


  unsigned sched_reset_on_fork:1;

  // pid和组id
  pid_t pid;
  pid_t tgid;

#ifdef CONFIG_CC_STACKPROTECTOR
  unsigned long stack_canary;
#endif

  /* 
   * 分别指向原父进程
   * 最年轻的子进程
   * 年幼的兄弟进程
   * 年长的兄弟进程的指针
   */
  struct task_struct *real_parent;
  struct task_struct *parent;
  struct list_head children;
  struct list_head sibling;
  // 线程组的组长
  struct task_struct *group_leader;

  struct list_head ptraced;
  struct list_head ptrace_entry;

  struct bts_context *bts;

  /* PID/PID散列表的关系 */
  struct pid_link pids[PIDTYPE_MAX];
  struct list_head thread_group;

  // 用于vfork()
  struct completion *vfork_done;
  // CLONE_CHILD_SETTID
  int __user *set_child_tid;
  // CLONE_CHILD_CLEARTID
  int __user *clear_child_tid;

  cputime_t utime, stime, utimescaled, stimescaled;
  cputime_t gtime;
  cputime_t prev_utime, prev_stime;
  // 上下文切换计数器
  unsigned long nvcsw, nivcsw;
  // 单调时间
  struct timespec start_time;
  // 启动以来的时间
  struct timespec real_start_time;
  // 内存管理器失效和页交换信息
  unsigned long min_flt, maj_flt;

  struct task_cputime cputime_expires;
  struct list_head cpu_timers[3];

/* 进程身份 */
  const struct cred *real_cred;
  const struct cred *cred;
  struct mutex cred_guard_mutex;
  struct cred *replacement_session_keyring;

  char comm[TASK_COMM_LEN];

/* 文件系统信息 */
  int link_count, total_link_count;
#ifdef CONFIG_SYSVIPC
/* ipc相关信息 */
  struct sysv_sem sysvsem;
#endif
#ifdef CONFIG_DETECT_HUNG_TASK
  unsigned long last_switch_count;
#endif
/* 当前进程特定于CPU的状态信息 */
  struct thread_struct thread;
/* 文件系统信息 */
  struct fs_struct *fs;
/* 打开文件信息 */
  struct files_struct *files;
/* 命名空间 */
  struct nsproxy *nsproxy;
/* 信号处理程序 */
  struct signal_struct *signal;
  struct sighand_struct *sighand;

  sigset_t blocked, real_blocked;
  sigset_t saved_sigmask;
  struct sigpending pending;

  unsigned long sas_ss_sp;
  size_t sas_ss_size;
  int (*notifier)(void *priv);
  void *notifier_data;
  sigset_t *notifier_mask;
  struct audit_context *audit_context;
#ifdef CONFIG_AUDITSYSCALL
  uid_t loginuid;
  unsigned int sessionid;
#endif
  seccomp_t seccomp;

/* 进程组的信息 */
    u32 parent_exec_id;
    u32 self_exec_id;
  // 保护mm,files等信息的自旋锁
  spinlock_t alloc_lock;

#ifdef CONFIG_GENERIC_HARDIRQS
  /* IRQ处理进程 */
  struct irqaction *irqaction;
#endif

  spinlock_t pi_lock;

#ifdef CONFIG_RT_MUTEXES
  struct plist_head pi_waiters;
  struct rt_mutex_waiter *pi_blocked_on;
#endif

#ifdef CONFIG_DEBUG_MUTEXES
  struct mutex_waiter *blocked_on;
#endif
#ifdef CONFIG_TRACE_IRQFLAGS
  unsigned int irq_events;
  int hardirqs_enabled;
  unsigned long hardirq_enable_ip;
  unsigned int hardirq_enable_event;
  unsigned long hardirq_disable_ip;
  unsigned int hardirq_disable_event;
  int softirqs_enabled;
  unsigned long softirq_disable_ip;
  unsigned int softirq_disable_event;
  unsigned long softirq_enable_ip;
  unsigned int softirq_enable_event;
  int hardirq_context;
  int softirq_context;
#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];
  gfp_t lockdep_reclaim_gfp;
#endif

/* 日志文件系统信息 */
  void *journal_info;

/* 快设备信息 */
  struct bio *bio_list, **bio_tail;

/* 虚拟内存状态 */
  struct reclaim_state *reclaim_state;

  struct backing_dev_info *backing_dev_info;

  struct io_context *io_context;

  unsigned long ptrace_message;
  siginfo_t *last_siginfo;
  struct task_io_accounting ioac;
#if defined(CONFIG_TASK_XACCT)
  u64 acct_rss_mem1;
  u64 acct_vm_mem1;
  cputime_t acct_timexpd; /* stime + utime since last update */
#endif
#ifdef CONFIG_CPUSETS
  nodemask_t mems_allowed;
  int cpuset_mem_spread_rotor;
#endif
#ifdef CONFIG_CGROUPS
  struct css_set *cgroups;
  struct list_head cg_list;
#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;
#endif
#ifdef CONFIG_PERF_EVENTS
  struct perf_event_context *perf_event_ctxp;
  struct mutex perf_event_mutex;
  struct list_head perf_event_list;
#endif
#ifdef CONFIG_NUMA
  struct mempolicy *mempolicy;
  short il_next;
#endif
  atomic_t fs_excl;
  struct rcu_head rcu;

  // ...

进程资源限制

每个进程都有一组相关的资源限制(resource limit),限制指定了进程能使用的系统资源数量。这些资源限制避免用户过分使用系统资源(CPU,磁盘空间等)。堆当前进程的资源限制存放在current->signal->rlim字段,即进程描述符的一个字段。这个字段类型为rlimit结构的数组,每个资源限制对应一个元素:

struct rlimit {
    unsigned long rlim_cur;
    unsigned long rlim_max;
};

资源限制包括:

字段名 说明
RLIMIT_AS 进程地址空间的最大数,以字节为单位,当进程使用malloc或相关函数的时候会检查这个值
RLIMIT_CORE 内存信息转储文件的大小,当一个进程异常终止时,内核在进程的当前目录下创建内存信息转储文件之前检查这个值
RLIMIT_CPU 进程使用CPU的最长时间,以秒为单位
RLIMIT_DATA 堆大小的最大值
RLIMIT_FSIZE 文件大小的最大值,如果进程把一个文件的大小扩充到这个值,内核就给这个进程发送SIGXFSZ信号
RLIMIT_LOCKS 文件锁数量的最大值
RLIMIT_MEMLOCK 非交换内存的最大值,当进程试图通过mlock或者mlockall锁住页框时,会检查这个值
RLIMIT_MSGOUEUE POSIX消息队列中的最大字节数
RLIMIT_NOFILE 打开文件描述符的最大数,打开一个文件或复制一个文件时会检查这个值
RLIMIT_NPROC 用户能拥有的进程最大数
RLIMIT_RSS 进程锁拥有的页框最大数
RLIMIT_SIGPENDING 进程挂起信号的最大数
RLIMIT_STACK 栈大小的最大值,内核在扩充进程的用户态堆栈之前检查这个值

进程描述符  http://guojing.me/linux-kernel-architecture/posts/process-descriptor/#fn:3


这个讲得比较清楚:

【Linux】窥探Linux内核task_struct结构体

task_struct的定义及注释


Linux内核2.6.32版的task_struct源码

struct task_struct {
    volatile long state;    /* -1 unrunnable, 0 runnable, >0 stopped */
    void *stack;
    atomic_t usage;
    unsigned int flags; /* per process flags, defined below */
    unsigned int ptrace;

    int lock_depth;     /* BKL lock depth */

#ifdef CONFIG_SMP
#ifdef __ARCH_WANT_UNLOCKED_CTXSW
    int oncpu;
#endif
#endif

    int prio, static_prio, normal_prio;
    unsigned int rt_priority;
    const struct sched_class *sched_class;
    struct sched_entity se;
    struct sched_rt_entity rt;

#ifdef CONFIG_PREEMPT_NOTIFIERS
    /* list of struct preempt_notifier: */
    struct hlist_head preempt_notifiers;
#endif

    /*
     * fpu_counter contains the number of consecutive context switches
     * that the FPU is used. If this is over a threshold, the lazy fpu
     * saving becomes unlazy to save the trap. This is an unsigned char
     * so that after 256 times the counter wraps and the behavior turns
     * lazy again; this to deal with bursty apps that only use FPU for
     * a short time
     */
    unsigned char fpu_counter;
#ifdef CONFIG_BLK_DEV_IO_TRACE
    unsigned int btrace_seq;
#endif

    unsigned int policy;
    cpumask_t cpus_allowed;

#ifdef CONFIG_TREE_PREEMPT_RCU
    int rcu_read_lock_nesting;
    char rcu_read_unlock_special;
    struct rcu_node *rcu_blocked_node;
    struct list_head rcu_node_entry;
#endif /* #ifdef CONFIG_TREE_PREEMPT_RCU */

#if defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT)
    struct sched_info sched_info;
#endif

    struct list_head tasks;
    struct plist_node pushable_tasks;

    struct mm_struct *mm, *active_mm;

/* task state */
    int exit_state;
    int exit_code, exit_signal;
    int pdeath_signal;  /*  The signal sent when the parent dies  */
    /* ??? */
    unsigned int personality;
    unsigned did_exec:1;
    unsigned in_execve:1;   /* Tell the LSMs that the process is doing an
                 * execve */
    unsigned in_iowait:1;


    /* Revert to default priority/policy when forking */
    unsigned sched_reset_on_fork:1;

    pid_t pid;
    pid_t tgid;

#ifdef CONFIG_CC_STACKPROTECTOR
    /* Canary value for the -fstack-protector gcc feature */
    unsigned long stack_canary;
#endif

    /* 
     * pointers to (original) parent process, youngest child, younger sibling,
     * older sibling, respectively.  (p->father can be replaced with 
     * p->real_parent->pid)
     */
    struct task_struct *real_parent; /* real parent process */
    struct task_struct *parent; /* recipient of SIGCHLD, wait4() reports */
    /*
     * children/sibling forms the list of my natural children
     */
    struct list_head children;  /* list of my children */
    struct list_head sibling;   /* linkage in my parent's children list */
    struct task_struct *group_leader;   /* threadgroup leader */

    /*
     * ptraced is the list of tasks this task is using ptrace on.
     * This includes both natural children and PTRACE_ATTACH targets.
     * p->ptrace_entry is p's link on the p->parent->ptraced list.
     */
    struct list_head ptraced;
    struct list_head ptrace_entry;

    /*
     * This is the tracer handle for the ptrace BTS extension.
     * This field actually belongs to the ptracer task.
     */
    struct bts_context *bts;

    /* PID/PID hash table linkage. */
    struct pid_link pids[PIDTYPE_MAX];
    struct list_head thread_group;

    struct completion *vfork_done;      /* for vfork() */
    int __user *set_child_tid;      /* CLONE_CHILD_SETTID */
    int __user *clear_child_tid;        /* CLONE_CHILD_CLEARTID */

    cputime_t utime, stime, utimescaled, stimescaled;
    cputime_t gtime;
    cputime_t prev_utime, prev_stime;
    unsigned long nvcsw, nivcsw; /* context switch counts */
    struct timespec start_time;         /* monotonic time */
    struct timespec real_start_time;    /* boot based time */
/* mm fault and swap info: this can arguably be seen as either mm-specific or thread-specific */
    unsigned long min_flt, maj_flt;

    struct task_cputime cputime_expires;
    struct list_head cpu_timers[3];

/* process credentials */
    const struct cred *real_cred;   /* objective and real subjective task
                     * credentials (COW) */
    const struct cred *cred;    /* effective (overridable) subjective task
                     * credentials (COW) */
    struct mutex cred_guard_mutex;  /* guard against foreign influences on
                     * credential calculations
                     * (notably. ptrace) */
    struct cred *replacement_session_keyring; /* for KEYCTL_SESSION_TO_PARENT */

    char comm[TASK_COMM_LEN]; /* executable name excluding path
                     - access with [gs]et_task_comm (which lock
                       it with task_lock())
                     - initialized normally by flush_old_exec */
/* file system info */
    int link_count, total_link_count;
#ifdef CONFIG_SYSVIPC
/* ipc stuff */
    struct sysv_sem sysvsem;
#endif
#ifdef CONFIG_DETECT_HUNG_TASK
/* hung task detection */
    unsigned long last_switch_count;
#endif
/* CPU-specific state of this task */
    struct thread_struct thread;
/* filesystem information */
    struct fs_struct *fs;
/* open file information */
    struct files_struct *files;
/* namespaces */
    struct nsproxy *nsproxy;
/* signal handlers */
    struct signal_struct *signal;
    struct sighand_struct *sighand;

    sigset_t blocked, real_blocked;
    sigset_t saved_sigmask; /* restored if set_restore_sigmask() was used */
    struct sigpending pending;

    unsigned long sas_ss_sp;
    size_t sas_ss_size;
    int (*notifier)(void *priv);
    void *notifier_data;
    sigset_t *notifier_mask;
    struct audit_context *audit_context;
#ifdef CONFIG_AUDITSYSCALL
    uid_t loginuid;
    unsigned int sessionid;
#endif
    seccomp_t seccomp;

/* Thread group tracking */
    u32 parent_exec_id;
    u32 self_exec_id;
/* Protection of (de-)allocation: mm, files, fs, tty, keyrings, mems_allowed,
 * mempolicy */
    spinlock_t alloc_lock;

#ifdef CONFIG_GENERIC_HARDIRQS
    /* IRQ handler threads */
    struct irqaction *irqaction;
#endif

    /* Protection of the PI data structures: */
    spinlock_t pi_lock;

#ifdef CONFIG_RT_MUTEXES
    /* PI waiters blocked on a rt_mutex held by this task */
    struct plist_head pi_waiters;
    /* 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_TRACE_IRQFLAGS
    unsigned int irq_events;
    int hardirqs_enabled;
    unsigned long hardirq_enable_ip;
    unsigned int hardirq_enable_event;
    unsigned long hardirq_disable_ip;
    unsigned int hardirq_disable_event;
    int softirqs_enabled;
    unsigned long softirq_disable_ip;
    unsigned int softirq_disable_event;
    unsigned long softirq_enable_ip;
    unsigned int softirq_enable_event;
    int hardirq_context;
    int softirq_context;
#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];
    gfp_t lockdep_reclaim_gfp;
#endif

/* journalling filesystem info */
    void *journal_info;

/* stacked block device info */
    struct bio *bio_list, **bio_tail;

/* VM state */
    struct reclaim_state *reclaim_state;

    struct backing_dev_info *backing_dev_info;

    struct io_context *io_context;

    unsigned long ptrace_message;
    siginfo_t *last_siginfo; /* For ptrace use.  */
    struct task_io_accounting ioac;
#if defined(CONFIG_TASK_XACCT)
    u64 acct_rss_mem1;  /* accumulated rss usage */
    u64 acct_vm_mem1;   /* accumulated virtual memory usage */
    cputime_t acct_timexpd; /* stime + utime since last update */
#endif
#ifdef CONFIG_CPUSETS
    nodemask_t mems_allowed;    /* Protected by alloc_lock */
    int cpuset_mem_spread_rotor;
#endif
#ifdef CONFIG_CGROUPS
    /* Control Group info protected by css_set_lock */
    struct css_set *cgroups;
    /* cg_list protected by css_set_lock and tsk->alloc_lock */
    struct list_head cg_list;
#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;
#endif
#ifdef CONFIG_PERF_EVENTS
    struct perf_event_context *perf_event_ctxp;
    struct mutex perf_event_mutex;
    struct list_head perf_event_list;
#endif
#ifdef CONFIG_NUMA
    struct mempolicy *mempolicy;    /* Protected by alloc_lock */
    short il_next;
#endif
    atomic_t fs_excl;   /* holding fs exclusive resources */
    struct rcu_head rcu;

    /*
     * cache last used pipe for splice
     */
    struct pipe_inode_info *splice_pipe;
#ifdef  CONFIG_TASK_DELAY_ACCT
    struct task_delay_info *delays;
#endif
#ifdef CONFIG_FAULT_INJECTION
    int make_it_fail;
#endif
    struct prop_local_single dirties;
#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.
     */
    unsigned long timer_slack_ns;
    unsigned long default_timer_slack_ns;

    struct list_head    *scm_work_list;
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
    /* Index of current stored adress in ret_stack */
    int curr_ret_stack;
    /* Stack of return addresses for return function tracing */
    struct ftrace_ret_stack *ret_stack;
    /* time stamp for last schedule */
    unsigned long long ftrace_timestamp;
    /*
     * Number of functions that haven't been traced
     * because of depth overrun.
     */
    atomic_t trace_overrun;
    /* Pause for the tracing */
    atomic_t tracing_graph_pause;
#endif
#ifdef CONFIG_TRACING
    /* state flags for use by tracers */
    unsigned long trace;
    /* bitmask of trace recursion */
    unsigned long trace_recursion;
#endif /* CONFIG_TRACING */
    unsigned long stack_start;
};

 

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

【Linux】进程描述符 的相关文章

  • 如何从 Linux 的 shell 中删除所有以 ._ 开头的文件?

    确实如标题所示 我已将许多文件从 Mac 复制到 Raspberry Pi 这导致了许多以前缀开头的多余文件 我想删除以以下开头的文件夹中的每个文件 我该怎么做 尝试类似的方法 cd path to directory rm rf 或者 如
  • Linux命令列出所有可用命令和别名

    是否有一个 Linux 命令可以列出该终端会话的所有可用命令和别名 就好像您输入 a 并按下 Tab 键一样 但针对的是字母表中的每个字母 或者运行 别名 但也返回命令 为什么 我想运行以下命令并查看命令是否可用 ListAllComman
  • 确保 config.h 包含一次

    我有一个库项目 正在使用 Linux 中的 autotools 套件移植到该项目 我对自动工具很陌生 本周 我已经了解了其操作的基础知识 我有一个关于如何保留内容的问题config h免遭重新定义 我惊讶地发现生成的config h文件也没
  • python:numpy 运行脚本两次

    当我将 numpy 导入到 python 脚本中时 该脚本会执行两次 有人可以告诉我如何阻止这种情况 因为我的脚本中的所有内容都需要两倍的时间 这是一个例子 usr bin python2 from numpy import print t
  • 将数组传递给函数名称冲突

    Specs GNU bash 版本 3 1 17 无法升级 Premise 我一直在摆弄数组 我想知道是否有任何方法可以让函数的本地变量与所述函数外部的数组同名 Example 在下面的示例中 我将尝试显示该问题 Working bin b
  • 如何成功使用RDAP协议代替whois

    我对新的 RDAP 协议有点困惑 也不知道何时进一步追求它有意义 在我看来 每个人都同意它是 whois 的继承者 但他们的数据库似乎是空的 在 ubuntu 上我尝试了 rdapper nicinfo 甚至他们的 RESTful API
  • 怎样才能使 Windows 成为一个开箱即用的 POSIX 兼容操作系统?

    这个问题的动机是我的一个牵强的梦想 即 nix 平台上可用的许多优秀软件可以轻松移植到 Windows 微软最近对开源和开放性采取了不同的方法 所以我真的很想知道如果微软有这样的倾向 这样的事情会有多可行 我很好奇的一些更具体的事情是 是否
  • 如何在我的 AWS EC2 实例上安装特定字体?

    我有一个在 AWS EC2 Amazon Linux Elastic Beanstalk 实例上运行的 Python 应用程序 该实例需要某些特定字体才能生成输出 并且想知道如何在部署或实例启动过程中安装它们 我的代码在本地计算机 OS X
  • 如何让 clangd 转向 c++20

    当没有其他信息时 如何让 clangd 回退到 c 20 例如 在第一次构建之前 cmake 可以生成一个 这是在带有最新 LLVM 的 Arch Linux 上 这是通过 Emacs LSP 运行的 但这应该没有什么区别 你可以加 Com
  • gentoo crontab:为什么这个简单的 crontab 不起作用?

    我使用 GENTOO 发行版 crontab e 35 12 root php5 home www cron php 当我手动运行时 php5 php5 home www cron php 这有效 它向我发送了一封电子邮件 然后我检查日期
  • git在Windows和Linux之间切换后强制刷新索引

    我有一个Windows和Linux共享的磁盘分区 格式 NTFS 它包含一个 git 存储库 约 6 7 GB 如果我只使用Windows or 只使用Linux操作 git 存储库一切正常 但是每次切换系统的时候git status命令将
  • 在 LINUX 上使用 Python 连接到 OLAP 多维数据集

    我知道如何在 Windows 上使用 Python 连接到 MS OLAP 多维数据集 嗯 至少有一种方法 通常我使用 win32py 包并调用 COM 对象进行连接 import win32com client connection wi
  • 在 Ubuntu 16.04 上找不到 printf.c

    我最近切换到Ubuntu 16 04 我在用vscode作为 Ubuntu 上的 IDE 我配置了其他语言 但我无法做到这一点C C 我创建c cpp properties json launch json tasks json 当我开始编
  • 适用于 KDE 和 Gnome 的 Gui [重复]

    这个问题在这里已经有答案了 我想为一个现在是 CLI 的应用程序编写一个 gui 它需要在 KDE 和 Gnome DE 中 看起来不错 充分利用用户的外观设置 如果我选择 Qt 或 GTK 我能够做到这一点吗 它们与两个 DE 集成良好吗
  • 如何在特定 systemd 服务重新启动时触发自定义脚本运行

    我想知道如何安排自定义脚本在重新启动服务时运行 我的用例是 每当重新启动 Tomcat 服务时 我都必须运行多个命令 我想知道是否有一种方法可以编写脚本并安排它在重新启动 Tomcat 服务时运行 我已将 tomcat 脚本设置为 syst
  • 劫持系统调用

    我正在编写一个内核模块 我需要劫持 包装一些系统调用 我正在暴力破解 sys call table 地址 并使用 cr0 来禁用 启用页面保护 到目前为止一切顺利 一旦完成 我将公开整个代码 因此如果有人愿意 我可以更新这个问题 无论如何
  • 为什么 Linux 对目录使用 getdents() 而不是 read()?

    我浏览 K R C 时注意到 为了读取目录中的条目 他们使用了 while read dp gt fd char dirbuf sizeof dirbuf sizeof dirbuf code Where dirbuf是系统特定的目录结构
  • 在主目录中安装库

    在 Linux Ubuntu 中 我尝试运行一个工具 但它显示错误 库丢失 我无权在系统中安装任何内容 或者根本无法从我的用户帐户执行 sudo 是否可以在我的主目录 没有 sudo 中安装缺少的库 在我的例子中为 libstdc so 6
  • 如何模拟ARM处理器运行环境并加载Linux内核模块?

    我尝试加载我的vmlinux into gdb并使用 ARM 内核模拟器 但我不明白为什么我会得到Undefined target command sim 这是外壳输出 arm eabi gdb vmlinux GNU gdb GDB 7
  • QFileDialog::getSaveFileName 和默认的 selectedFilter

    我有 getSaveFileName 和一些过滤器 我希望当用户打开 保存 对话框时选择其中之一 Qt 文档说明如下 可以通过将 selectedFilter 设置为所需的值来选择默认过滤器 我尝试以下变体 QString selFilte

随机推荐

  • 函数使用注意事项

    1 自定义函数 lt 1 gt 无参数 无返回值 def 函数名 语句 lt 2 gt 无参数 有返回值 def 函数名 语句 return 需要返回的数值 注意 一个函数到底有没有返回值 就看有没有return 因为只有return才可以
  • 服务器修改字体,Win10 1909默认字体怎么修改?Win10 1909默认字体修改教程

    在使用Win10 1909设备的时候 偶尔需要创建一个全新的网络连接来进行文件的共享 但许多Win10 1909用户其实并不清楚 该怎么新建网络连接 针对这一情况 小编今天为大家带来了Win10 1909网络连接新建方法简述 方法步骤 打开
  • 基于组件化+模块化+Kotlin+协程+Flow+Retrofit+Jetpack+MVVM架构实现WanAndroid客户端

    前言 之前一直想写个 WanAndroid 项目来巩固自己对 Kotlin Jetpack 协程 等知识的学习 但是一直没有时间 这里重新行动起来 从项目搭建到完成前前后后用了两个月时间 平常时间比较少 基本上都是只能利用零碎的时间来写 但
  • 虚拟数字人详解|有个性、有情感的对话技术探索

    文 蔡华 华院计算 元宇宙是当前流行的的技术和商业热点 而其背后的核心技术是数字人 近日 华院计算算法研究员蔡华博士就虚拟数字人 有个性 有情感的对话技术 的话题进行了讲解 以下内容为蔡华博士的演讲内容节选 虚拟数字人的三重 境界 关于虚拟
  • STM32编译生成的BIN文件详解

    背景 在做stm32的IAP功能 大概思路参见我的另一篇文章 跟别人讨论了关于app中发生中断之后流程的问题 然后看了一下BIN文件格式 主要是因为BIN文件就是镜像 不包含任何其他信息 如下载的地址等 就是对ROM的绝对描述 可以很清楚看
  • 安卓端自行实现工信部要求的隐私合规检测一(教你手写Xposed模块代码)

    前言 友情提示 文章较长 源码及相关使用教程都在文尾 之所以写这篇文章 是因为不久前 我们公司上架的app被打回来了 信通院那边出了个报告 里面说我们app未经授权就自动获取了手机的mac地址 当时其实是有点懵逼的 因为合规措施其实是已经做
  • 七十九.找出唯一成对的数(位运算)

    1 N 这N个数放在含有N 1个元素的数组中 只有唯一的一个元素值重复 其它均只出现一次 每个数组元素只能访问一次 设计一个算法将它找出来 不用辅助存储空间 能否设计一个算法实现 import java util Random public
  • 引力搜索算法

    最近在论文中看到有学者用改进的引力搜索算法解优化问题 有一个较好的效果 于是去了解了一下这个算法 引力搜索算法 Gravitational Search Algorithm GSA 是Esmat Rashedi等人在2009年提出的一种随机
  • 微信小程序——前端——抵扣券、优惠券样式

    微信小程序 前端 抵扣券 优惠券样式 效果图 实现思路 左边 划线 右边 使用信息 分割线 使用限制 整体底色 wrapper margin 0 auto width 100 display flex background linear g
  • 程序,进程和线程

    注 并发和并行是有区别的 并发是在同一时间段内同时运行 本质上还没有同时 而并行则是在同一时刻同时运行 一 程序 进程和线程之间的关系 1 一个应用程序是由许多个程序段组成 2 进程是由程序段 相关的数据段和PCB 进程控制块 组成 进程是
  • Java中“附近的人”实现方案讨论及代码实现

    在我们平时使用的许多app中有附近的人这一功能 像微信 qq附近的人 哈罗 街兔附近的车辆 这些功能就在我们日常生活中出现 像类似于附近的人这一类业务 在Java中是如何实现的呢 本文就简单介绍下目前的几种解决方案 并提供简单的示例代码 注
  • 46 最佳实践-性能最佳实践-内存大页

    文章目录 46 最佳实践 性能最佳实践 内存大页 46 1 概述 46 2 操作指导 46 最佳实践 性能最佳实践 内存大页 46 1 概述 相比传统的4K内存分页 openEuler也支持2MB 1GB的大内存分页 内存大页可以有效减少T
  • failed with initial frozen solve. Retrying with flexible solve. 什么意思?

    这通常是指一个软件包管理器 如pip conda等 在尝试安装某个软件包时遇到了问题 并且在第一次尝试使用 frozen solve 方法时失败了 Frozen solve 是一种求解器的方法 它会尝试使用已知的软件包版本和其依赖项版本来解
  • AD如何快速更改元件库器件的颜色

    如何你想在原理图库中快速修改元件的颜色 一根根线去点肯定是太慢了 可能第一反应就是查找相似 把颜色不是目标颜色全部选中 然后统一更改 但是在原理图库中 这一做法是行不通的 例如下图 可以在右上方找到筛选器 先选中Lines改成自己想要的颜色
  • 计算机网络思维导图

    计算机网络思维导图 按照计算机网络的TCP IP四层模型构建 物理层对应网络接口层的功能 这个是之前期末考试时做的思维导图 现在复习专业课发现里面还有很多缺漏 希望大家多多提意见 后期有时间我也会查漏补缺的 谢谢支持 目录 计算机网络思维导
  • 集成运算放大电路实验报告_模电总结:第三章、集成运算放大电路

    我的公众号 每日晴天 可关注领取我的笔记pdf版哦 部分英文 d差模 different 差模的d c 共模 common mode 3 1多级放大电路 1 多级放大电路的组成 输入级 输入电阻高 噪声和漂移小 中间级 具有足够大的放大能力
  • android httpClient 支持HTTPS的2种处理方式

    项目中Android https或http请求地址重定向为HTTPS的地址 相信很多人都遇到了这个异常 无终端认证 javax net ssl SSLPeerUnverifiedException No peer certificate 1
  • YoloV4训练自己的数据集

    YoloV4训练自己的数据集 1 建立工作文件夹 2 准备训练数据集 3 修改配置文件 4 Anchor Box先验框聚类分析与修改 5 训练自己的数据集 6 测试训练出来的网络模型 7 性能统计 1 建立工作文件夹 新建一个项目文件夹 用
  • STM32/AMP32F407进入低功耗待机模式后立马被唤醒的解决办法

    最近项目用到低功耗 但是调试发现进入待机就被唤醒的问题 清除WU SB两个唤醒标志位 也依然被立马唤醒一次 进入待机模式 HAL PWR EnterSTANDBYMode 通过极海的数据手册终于发现 我们在使能WAKE UP PA 0唤醒脚
  • 【Linux】进程描述符

    linux进程管理 1 进程描述符 进程描述符 Linux使用进程描述符数据结构记录现场信息 然后给予进程描述符管理进程 包括进程的创建 调度 消亡等操作 进程除了包括运行着的程序 还包括系统资源 当前CPU现场 调度信息 进程间关系等 记