Skip to content

Commit

Permalink
[smart] fixup of lwp recycling and mm varea (#8206)
Browse files Browse the repository at this point in the history
Signed-off-by: shell <[email protected]>
Signed-off-by: Shell <[email protected]>
Co-authored-by: xqyjlj <[email protected]>
  • Loading branch information
polarvid and xqyjlj authored Nov 2, 2023
1 parent 1b6f0e8 commit c2036e7
Show file tree
Hide file tree
Showing 17 changed files with 457 additions and 290 deletions.
4 changes: 4 additions & 0 deletions components/dfs/dfs_v2/src/dfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,10 @@ void fdt_fd_release(struct dfs_fdtable *fdt, int fd)
if (file && file->ref_count == 1)
{
rt_mutex_detach(&file->pos_lock);
if (file->mmap_context)
{
rt_free(file->mmap_context);
}
rt_free(file);
}
else
Expand Down
1 change: 0 additions & 1 deletion components/lwp/libc_musl.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
#define PMUTEX_DESTROY 3

/* for sys/mman.h */
#define MAP_FAILED ((void *)-1)

#define MAP_SHARED 0x01
#define MAP_PRIVATE 0x02
Expand Down
10 changes: 8 additions & 2 deletions components/lwp/lwp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1157,6 +1157,10 @@ rt_err_t lwp_children_register(struct rt_lwp *parent, struct rt_lwp *child)
LWP_UNLOCK(parent);

LOG_D("%s(parent=%p, child=%p)", __func__, parent, child);
/* parent holds reference to child */
lwp_ref_inc(parent);
/* child holds reference to parent */
lwp_ref_inc(child);

return 0;
}
Expand All @@ -1178,6 +1182,8 @@ rt_err_t lwp_children_unregister(struct rt_lwp *parent, struct rt_lwp *child)
LWP_UNLOCK(parent);

LOG_D("%s(parent=%p, child=%p)", __func__, parent, child);
lwp_ref_dec(child);
lwp_ref_dec(parent);

return 0;
}
Expand All @@ -1195,7 +1201,7 @@ pid_t lwp_execve(char *filename, int debug, int argc, char **argv, char **envp)

if (filename == RT_NULL)
{
return -RT_ERROR;
return -EINVAL;
}

if (access(filename, X_OK) != 0)
Expand All @@ -1208,7 +1214,7 @@ pid_t lwp_execve(char *filename, int debug, int argc, char **argv, char **envp)
if (lwp == RT_NULL)
{
dbg_log(DBG_ERROR, "lwp struct out of memory!\n");
return -RT_ENOMEM;
return -ENOMEM;
}
LOG_D("lwp malloc : %p, size: %d!", lwp, sizeof(struct rt_lwp));

Expand Down
1 change: 0 additions & 1 deletion components/lwp/lwp.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ char *lwp_getcwd(void);
void lwp_request_thread_exit(rt_thread_t thread_to_exit);
int lwp_check_exit_request(void);
void lwp_terminate(struct rt_lwp *lwp);
void lwp_wait_subthread_exit(void);

int lwp_tid_init(void);
int lwp_tid_get(void);
Expand Down
Loading

0 comments on commit c2036e7

Please sign in to comment.