fs/procfs: Remove the unnecessary critical section
This commit is contained in:
parent
4e8b3ebb8a
commit
1e0e1ae856
@ -553,7 +553,6 @@ static int procfs_opendir(FAR struct inode *mountpt, FAR const char *relpath,
|
||||
FAR struct procfs_level0_s *level0;
|
||||
FAR struct procfs_dir_priv_s *dirpriv;
|
||||
FAR void *priv = NULL;
|
||||
irqstate_t flags;
|
||||
|
||||
finfo("relpath: \"%s\"\n", relpath ? relpath : "NULL");
|
||||
DEBUGASSERT(mountpt && relpath && dir && !dir->u.procfs);
|
||||
@ -587,9 +586,7 @@ static int procfs_opendir(FAR struct inode *mountpt, FAR const char *relpath,
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_FS_PROCFS_EXCLUDE_PROCESS
|
||||
flags = enter_critical_section();
|
||||
sched_foreach(procfs_enum, level0);
|
||||
leave_critical_section(flags);
|
||||
#else
|
||||
level0->base.index = 0;
|
||||
level0->base.nentries = 0;
|
||||
@ -715,7 +712,6 @@ static int procfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir)
|
||||
FAR struct tcb_s *tcb;
|
||||
FAR const char *name = NULL;
|
||||
unsigned int index;
|
||||
irqstate_t flags;
|
||||
pid_t pid;
|
||||
int ret = -ENOENT;
|
||||
|
||||
@ -839,10 +835,7 @@ static int procfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir)
|
||||
|
||||
pid = level0->pid[index];
|
||||
|
||||
flags = enter_critical_section();
|
||||
tcb = sched_gettcb(pid);
|
||||
leave_critical_section(flags);
|
||||
|
||||
if (!tcb)
|
||||
{
|
||||
ferr("ERROR: PID %d is no longer valid\n", (int)pid);
|
||||
|
@ -1268,7 +1268,6 @@ static int proc_open(FAR struct file *filep, FAR const char *relpath,
|
||||
FAR const struct proc_node_s *node;
|
||||
FAR struct tcb_s *tcb;
|
||||
FAR char *ptr;
|
||||
irqstate_t flags;
|
||||
unsigned long tmp;
|
||||
pid_t pid;
|
||||
|
||||
@ -1326,10 +1325,7 @@ static int proc_open(FAR struct file *filep, FAR const char *relpath,
|
||||
|
||||
pid = (pid_t)tmp;
|
||||
|
||||
flags = enter_critical_section();
|
||||
tcb = sched_gettcb(pid);
|
||||
leave_critical_section(flags);
|
||||
|
||||
if (tcb == NULL)
|
||||
{
|
||||
ferr("ERROR: PID %d is no longer valid\n", (int)pid);
|
||||
@ -1404,7 +1400,6 @@ static ssize_t proc_read(FAR struct file *filep, FAR char *buffer,
|
||||
{
|
||||
FAR struct proc_file_s *procfile;
|
||||
FAR struct tcb_s *tcb;
|
||||
irqstate_t flags;
|
||||
ssize_t ret;
|
||||
|
||||
finfo("buffer=%p buflen=%d\n", buffer, (int)buflen);
|
||||
@ -1416,13 +1411,10 @@ static ssize_t proc_read(FAR struct file *filep, FAR char *buffer,
|
||||
|
||||
/* Verify that the thread is still valid */
|
||||
|
||||
flags = enter_critical_section();
|
||||
tcb = sched_gettcb(procfile->pid);
|
||||
|
||||
if (tcb == NULL)
|
||||
{
|
||||
ferr("ERROR: PID %d is not valid\n", (int)procfile->pid);
|
||||
leave_critical_section(flags);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
@ -1471,8 +1463,6 @@ static ssize_t proc_read(FAR struct file *filep, FAR char *buffer,
|
||||
break;
|
||||
}
|
||||
|
||||
leave_critical_section(flags);
|
||||
|
||||
/* Update the file offset */
|
||||
|
||||
if (ret > 0)
|
||||
@ -1535,7 +1525,6 @@ static int proc_opendir(FAR const char *relpath, FAR struct fs_dirent_s *dir)
|
||||
FAR struct proc_dir_s *procdir;
|
||||
FAR const struct proc_node_s *node;
|
||||
FAR struct tcb_s *tcb;
|
||||
irqstate_t flags;
|
||||
unsigned long tmp;
|
||||
FAR char *ptr;
|
||||
pid_t pid;
|
||||
@ -1586,10 +1575,7 @@ static int proc_opendir(FAR const char *relpath, FAR struct fs_dirent_s *dir)
|
||||
|
||||
pid = (pid_t)tmp;
|
||||
|
||||
flags = enter_critical_section();
|
||||
tcb = sched_gettcb(pid);
|
||||
leave_critical_section(flags);
|
||||
|
||||
if (tcb == NULL)
|
||||
{
|
||||
ferr("ERROR: PID %d is not valid\n", (int)pid);
|
||||
@ -1690,7 +1676,6 @@ static int proc_readdir(struct fs_dirent_s *dir)
|
||||
FAR const struct proc_node_s *node = NULL;
|
||||
FAR struct tcb_s *tcb;
|
||||
unsigned int index;
|
||||
irqstate_t flags;
|
||||
pid_t pid;
|
||||
int ret;
|
||||
|
||||
@ -1718,10 +1703,7 @@ static int proc_readdir(struct fs_dirent_s *dir)
|
||||
|
||||
pid = procdir->pid;
|
||||
|
||||
flags = enter_critical_section();
|
||||
tcb = sched_gettcb(pid);
|
||||
leave_critical_section(flags);
|
||||
|
||||
if (tcb == NULL)
|
||||
{
|
||||
ferr("ERROR: PID %d is no longer valid\n", (int)pid);
|
||||
@ -1794,7 +1776,6 @@ static int proc_stat(const char *relpath, struct stat *buf)
|
||||
FAR struct tcb_s *tcb;
|
||||
unsigned long tmp;
|
||||
FAR char *ptr;
|
||||
irqstate_t flags;
|
||||
pid_t pid;
|
||||
|
||||
/* Two path forms are accepted:
|
||||
@ -1837,10 +1818,7 @@ static int proc_stat(const char *relpath, struct stat *buf)
|
||||
|
||||
pid = (pid_t)tmp;
|
||||
|
||||
flags = enter_critical_section();
|
||||
tcb = sched_gettcb(pid);
|
||||
leave_critical_section(flags);
|
||||
|
||||
if (tcb == NULL)
|
||||
{
|
||||
ferr("ERROR: PID %d is no longer valid\n", (int)pid);
|
||||
|
Loading…
Reference in New Issue
Block a user