Tell the interviewer that it depends entirely on the implementation of the OS.
Take Windows x86 for example. There are only 2 segments [1], Code and Data. And they're both mapped to the whole 2GB (linear, user) address space. Base=0, Limit=2GB. They would've made one but x86 doesn't allow a segment to be both Read/Write and Execute. So they made two, and set CS to point to the code descriptor, and the rest (DS, ES, SS, etc) to point to the other [2]. But both point to the same stuff!
The person interviewing you had made a hidden assumption that he/she did not state, and that is a stupid trick to pull.
So regarding
Q. So tell me which segment thread share?
The segments are irrelevant to the question, at least on Windows. Threads share the whole address space. There is only 1 stack segment, SS, and it points to the exact same stuff that DS, ES, and CS do [2]. I.e. the whole bloody user space. 0-2GB. Of course, that doesn't mean threads only have 1 stack. Naturally each has its own stack, but x86 segments are not used for this purpose.
Maybe *nix does something different. Who knows. The premise the question was based on was broken.
- At least for user space.
- From
ntsd notepad
: cs=001b ss=0023 ds=0023 es=0023