开发平台(Platform): (Ex: VC++, GCC, Linux, ...)
Android Linux
额外使用到的函数库(Library Used): (Ex: OpenGL, ...)
None
问题(Question):
我自己实作一个function去开底层的file node(/dev/XXX)
并将这个function包成native library透过JNI给app使用
在执行app的时候 app本身的程式也会去使用同一file node(另一个library)
app也会呼叫我包好的native library 意思就是说file node会被开启两次
第一次是app其他process去呼叫的
另一次则是load native library去呼叫的
我有试着在open file node前加mutex做保护 但是不知道这样是不是正确的
pthread_mutex_lock(&mutex);
ret = open(/dev/XXX, O_RDWR);
...
close(/dev/XXX);
pthread_mutex_unlock(&mutex);
我发现这样好像挡不了file node被重复开的现象
不知道我是否要在加其他的东西才能挡到呢?