从helper.c中的fuse_main_common函数开始

fuse_main_common->

   fuse_loop_mt(struct fuse *f) ->       fuse_mt.c

  fuse_session_loop_mt(struct fuse_session *se) ->    fuse_loop_mt.c

   fuse_loop_start_thread(struct fuse_mt *mt)   ->    fuse_loop_mt.c

  fuse_start_thread(pthread_t *thread_id, void *(*func)(void *), void *arg)  ->   fuse_loop_mt.c

  res = pthread_create(thread_id, &attr, func, arg)              fuse_loop_mt.c

pthread_create 会创建一个新线程,运行函数 fuse_do_work ,该函数也在 fuse_loop_mt.c中。

 

在fuse_session_loop_mt中,会调用sem_wait(&mt.finish); 等待 fuse_do_work 线程。因此该后台线程可以一直运行。

在fuse_do_work的while循环中,每一次循环都启动一个线程 fuse_loop_start_thread(mt);

    

    

 

相关文章:

  • 2022-12-23
  • 2021-09-17
  • 2022-12-23
  • 2022-02-02
  • 2022-12-23
  • 2021-12-20
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-10-01
  • 2022-01-10
相关资源
相似解决方案