由买买提看人间百态

topics

全部话题 - 话题: reentrant
1 (共1页)
g********d
发帖数: 43
1
来自主题: JobHunting版 - 问几个multithreading的问题

call
accessed
"If it behaves correctly, it is called thread safe, or reentrant"
This is not correct. It is called thread safe, not reentrant. Reentrant is
more restrict.
量之
s*******e
发帖数: 27
2
来自主题: JobHunting版 - 问几个multithreading的问题
Thank you for pointing it out.
Before I made the my previous post, I actually looked up in the Advenced
Programming ... book ( i am self learning Linux now) and I looked at it
again,
it says on page 402,
'If a function is reentrant with respect to multiple threads, we say that it
is thread safe. This doesn't tell us, however, whether the function is
reentrant with repsect to signal handlers, we say that a function that is
safe to be reentered from an asynchronous singal handler is async-signal
s
j*******d
发帖数: 8834
3
首先要搞清楚是什么样的OS,什么样的threading
有些OS只support user land threading, 那你的app里像disk io这些东东就要小心了
,还有就是threading本身是什么样的,non-preemptive 还是preemptive, preemptive
你要考虑thread-safe,reentrant..etc non-preemptive你要考虑func 主动context
switch的时候的reentrant。。。etc
还有就是怎么样manage你的thread pool,假设你不想create thread on demand的话。
c****s
发帖数: 241
4
来自主题: JobHunting版 - VMware的面试题
VMware是个很不错的公司,感觉中国人不多。这个是今年初的时候去面试的题目。
interviewed questions for 1st round phone screen:
1) Introduce the project you have done
2) Buffer overflow; exploitation
3) Big endian and little endian; how to check it with the program
4) How to check the memory address in stack is increasing or decreasing?
5) There is one 32-bit interger x. We want to swap the first two bits
and the last two bits. All other bits should be kept in the same.
6) What’s the depth first search
7) Reentrant function
8) How t
n****t
发帖数: 241
5
来自主题: JobHunting版 - Google校园面试题
我看到貌似正确的一个解法,加了很多限制条件。。。
面试题之二叉搜索树的中位数 收藏
这个问题不算是很常见的问题,基本上在中文的论坛社区没有看到过,遇见这个是因为
偶尔在http://www.ocf.berkeley.edu/~wwu/cgi-bin/yabb/YaBB.cgi 上面注册了账号而看到的,题目如下:
Given a BST (Binary search Tree) how will you find median in that?
Constraints:
* No extra memory.
* Function should be reentrant (No static, global variables allowed.)
* Median for even no of nodes will be the average of 2 middle elements and
for odd no of terms will be middle element only.
* Algorithm should be efficient in terms of comple... 阅读全帖
g**e
发帖数: 6127
6
来自主题: JobHunting版 - java同步问题请教
pass a simple object to both threads, use synchronized keyword to lock this
object when you are accessing the DB.
or use reentrant lock (read/write lock maybe)
s********k
发帖数: 6180
7
系统是单线程,但是可能存在reentrant,这也会出现race condition吧?或者这就算
是多线程了?
k**w
发帖数: 376
8
来自主题: JobHunting版 - unix 面试题,求答案
>>fork,exec ipc,how many types of ipc
after fork, does new process get file handles and locks
>>what's are spin lock? are they better than mutex?
how many spinlocks work on smp and up architecure?
>>what will happen /can u have printf/printk inside an interrupt handler?
>>what's the difference between wake_up() and wake_up_interruptible() apis
in the linux kernel
when should sude which one, how it should be decided?
>>what's the difference between sleeep_on() and interruptible_sleep_on()
>>what ... 阅读全帖
f******p
发帖数: 173
9
来自主题: JobHunting版 - Thread safe strcpy ??
搜了一下,https://groups.google.com/forum/#!topic/microsoft.public.vc.mfc/
yBrUjgvGwf8 里面有一个回复我觉得挺不错,大家来说说怎样
Much better to allocate a block of storage (either a general "new" or
your own sub-allocator), copy the string into it, pass it to the recipient,
and let the
recipient release it (either delete or your own deallocation back to your
pool of
buffers). This means that there is never more than one thread, ever, using
the storage.
You do not protect the function; you protect the area it is copying ... 阅读全帖
d*******r
发帖数: 23
10
来自主题: JobHunting版 - 贡献一个G家面试题

ReadBytes(
never mind. 狗了一下,就是要用static variable, 根本就不用考虑reentrant的问
题。不过这又是一个专为interview而设计的问题
f*******r
发帖数: 976
11
来自主题: JobHunting版 - U电面经历

我觉得你这个似乎有问题?
首先你返回true or false是O(1)吗?这种题目一般要求查询O(1) 复杂度,而你里面还
有for loop.我没细看。
=======================================================
你还是仔细看完再做评论,没看你就发表评论不好。还有一个就是这题根本没写O(1)的
复杂度。你可以写一个O(1)或者是O(-1)的给大家来欣赏一下。
其次,你时间判断 “counter[i].first >= current - 10” 我怎么觉得有点问题?
你下面调用
if (counter.quotaExceeded()) return;
std::cout << "g() " << count << std::endl;
如果在0.000000000秒有100次调用。第10.00000秒你执行if 判断,答案是不能再调用
了。
但实际上是可以调用的,因为假设你if判断执行了0.01毫秒,到第二行std::cout....
真正执行的时候,
第0.0000000000秒的已经过期了。
=============... 阅读全帖

发帖数: 1
12
来自主题: JobHunting版 - 再问一个blockingqueue的问题
jave 有reentrant lock,有实现算法可以保证线程之间fair,但是会造成performance
的degradation。想想也正常吧,no free lunch。
https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/locks/
ReentrantLock.html
t**j
发帖数: 418
13
今天电话联系了个structral engineer,人好像超级nice,让我先发照片过去,看完后
说没事,不用他们派人到现场看了,可以帮我省500刀。。。后来还给我发email画了比
较详细的图给我解释,下面是email的一部分。Inspector和这个professional的
structral engineer都说是shrinkage crack,看来不信都不信了,打算出手了。。。
Based on what I see in these images and experience, the crack looks to be a
shrinkage crack. The crack started at the beam pocket due to the reentrant
corner not due to beam stress or load on the wall. The crack in the floor is
also a shrinkage crack, and looks to be a planned crack line known as a “
c... 阅读全帖
s*****i
发帖数: 355
14
来自主题: Java版 - modify parameter, or return?
是,或者用reentrant read/write lock
g**e
发帖数: 6127
15
来自主题: Java版 - Singleton
there are similar questions like implement your own reentrant lock, your own
hashmap etc.
not very picky questions if the position is for senior 码工

there
ThreadLocal
g**e
发帖数: 6127
16
我现在就记得executor,semaphore,barrier,reentrant lock等常用的几个。不用忘
的很快,我以前还把每个class都用过一遍的,照样忘光
g**e
发帖数: 6127
17
前三个我以前面试都遇到过。包括Reentrant read write lock
p**********g
发帖数: 9558
18
来自主题: Programming版 - 这个函数有问题吗?
http://en.wikipedia.org/wiki/Reentrant
The above even mention the difference between them.
t****t
发帖数: 6806
19
来自主题: Programming版 - 这个函数有问题吗?
a function may use some global data. if you want it to be thread safe, just
put lock around the access. however, putting lock around the access can't
make it reentrant: image an interrupt happen when then lock is on. the
function is called again, then it can not get lock thus it is deadlocked.
b***y
发帖数: 2799
20
来自主题: Programming版 - [合集] 微软的一个面试题
☆─────────────────────────────────────☆
waab (waab) 于 (Mon Mar 24 17:17:01 2008) 提到:
Given a BST (Binary search Tree) how will you find median in that?
Constraints:
* No extra memory.
* Function should be reentrant (No static, global variables allowed.)
* Median for even no of nodes will be the average of 2 middle elements
and for odd no of terms will be middle element only.
* Algorithm should be efficient in terms of complexity.
Write a solid secure code for it.
我的想法:
1.是先遍
X****r
发帖数: 3557
21
来自主题: Programming版 - rand() in multitreading
You could just look at the man page ---
The function rand() is not reentrant or thread-safe, since it uses hid-
den state that is modified on each call. This might just be the seed
value to be used by the next call, or it might be something more elabo-
rate. In order to get reproducible behavior in a threaded application,
this state must be made explicit. The function rand_r() is supplied
with a pointer to an unsigned int, to be used as state. This is a very
small amount of state, so
s********k
发帖数: 6180
22
比较难说code,因为完全不在同一个文件里面。基本的是类似reentrant问题,系统接
收一个信息,然后改变Variable A,然后执行复杂操作,里面有改变A,同时系统也有
可能继续接收信息。
本身系统不是multithread的,但是这样会不会有问题?
H****S
发帖数: 1359
23
Semaphore是non-reentrant的,参考以下代码:
def foo() {
println("smile")
super.foo()
}
一个binary semaphoreh会出现死锁。
h**********c
发帖数: 4120
24
来自主题: Programming版 - 为什么javascript是好语言
java简单,我老目前还没遇到过哪个architect来教教我老reentrant lock, unsafe,
security manager
js那么牛B,我老见过的老中青,简单的integration automation都做不成,天天解释
不清楚的拉西问题一堆
k**w
发帖数: 376
25
来自主题: Unix版 - unix 面试题,求答案 (转载)
【 以下文字转载自 JobHunting 讨论区 】
发信人: klyw (mm), 信区: JobHunting
标 题: unix 面试题,求答案
发信站: BBS 未名空间站 (Thu Nov 24 23:28:35 2011, 美东)
>>fork,exec ipc,how many types of ipc
after fork, does new process get file handles and locks
>>what's are spin lock? are they better than mutex?
how many spinlocks work on smp and up architecure?
>>what will happen /can u have printf/printk inside an interrupt handler?
>>what's the difference between wake_up() and wake_up_interruptible() apis
in the linux kernel
when should... 阅读全帖
t****o
发帖数: 342
26
来自主题: MedicalCareer版 - Podcast notes 1: Tachycardia

春大侠也来捧场,多谢, 上次指点的预激综合征还历历在目,请有空的时候再多给讲arrythmia,谢拉~
这里是记下的答案,没有桥正过拼写,如果有错,还请大家指出,一起改正
1. What labs will you order to confirm the arrhythmia?
EKG, CXR-if with SOB
2. Name all the supraventricular tachycardia
sinus tachycardia, A fibrillation, A flutter, multifocal atrial tachycardia, atrioventricular reentrant tachycardia, atrioventricular reciprocating tachycardia, paroxysmal atrial tachycardia
3. Which of these tachycardia is associated with irregular rhythm?
multifocal atrial tachycardia, A
u******3
发帖数: 6
27
来自主题: Physics版 - 文献求助
1. Lattice theory for helix-coil induced reentrant isotropic-nematic
transitions
作者: Walker, J.S.; Vause, C.A.
会议: Proceedings of the Symposium on Liquid Crystals and Ordered Fluids 会
议地点: St. Louis, MO, USA 会议日期: 9-11 April 1984
Molecular Crystals and Liquid Crystals 卷: 110 期: 1-4 页: 349-67 出
版年: 1984
链接:http://www.tandfonline.com/doi/abs/10.1080/.U3YgG7Xvscw
1 (共1页)