title: What does the brk() system call do?
body: <p>According to Linux programmers manual:</p>
  <blockquote>
  <p>brk() and sbrk() change the location of the program break, which
  defines the end of the process's data segment.</p>
  </blockquote>
  <p>What does the data segment mean over here? Is it just the data segment or data, BSS, and heap combined?</p>
  <p>According to wiki <a href="https://en.wikipedia.org/w/index.php?title=Data_segment&amp;oldid=441263263" rel="noreferrer">Data segment</a>:</p>
  <blockquote>
  <p>Sometimes the data, BSS, and heap areas are collectively referred to as the &quot;data segment&quot;.</p>
  </blockquote>
  <p>I see no reason for changing the size of just the data segment. If it is data, <a href="https://en.wikipedia.org/wiki/.bss" rel="noreferrer">BSS</a> and heap collectively then it makes sense as heap will get more space.</p>
  <p>Which brings me to my second question. In all the articles I read so far, author says that heap grows upward and stack grows downward. But what they do not explain is what happens when heap occupies all the space between heap and stack?</p>
  <p><img src="https://i.stack.imgur.com/1aV6B.png" alt="enter image description here" /></p>