简体   繁体   中英

C program execution: Does it run in a process or a thread?

I run a sample hello world program in C using Code Blocks.

When it executes it says the process returned 0 .

I know that it is run by the Operating system.

I want to know a few things:

  1. Is the program I executed associated with a separate process or the OS allocates a separate thread to it?

  2. When a function is called in Windows 32 bit or 64 bit, is the code segment register also pushed to stack?

The answer to your question depends upon how you view a process.

IN the traditional process model where a process is a schedulable entity with an address space, you'd say that your program executed a process.

If you want to look at this traditional model as a process having a single thread, then your program ran in on thread.

It's just a word game.

If you're running on a system that schedules threads natively, then your program existed in a process that contained a thread where the execution took place.

There are no segments in 64-bit.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM