Howto compile multiple files?Remember,below showsoneof the solutionStep 1.Step 2.Step 3.gcc -c code.cbgcc-oprog本5*-PrepareallthesourcefilesImportant:theremustbeoneand onlyonefilecontainingthemainfunction.progCompilethem intoobjectConstructtheprogramcodesonebyone.togetherwithalltheobjectcodes16
How to compile multiple files? 16 Step 1. Prepare all the source files. Important: there must be one and only one file containing the main function. Step 2. Compile them into object codes one by one. Step 3. $ gcc –o prog *.o Construct the program together with all the object codes. $ gcc –c code.c . Remember, below shows one of the solution. *.c *.o prog
Conclusion on“whatis a program?"· A program is just an executable file!- It is static;-It maybe associated withdynamically-linkedfiles;“*.so" in Linux and “*.dll" in Windows. It may be compiled from more than one file17
Conclusion on “what is a program?” • A program is just an executable file! – It is static; – It may be associated with dynamically-linked files; • “*.so” in Linux and “*.dll” in Windows. • It may be compiled from more than one file 17
What is a process?Process18
18 What is a process? Process Process Process Process Process
ProcessinMemory· A process is a program in execution-Aprogram (an executablefile)becomes process when itis loaded into memory- ActiveProcessinmemoryWhat are they? Only the program code?19
Process in Memory • A process is a program in execution – A program (an executable file) becomes process when it is loaded into memory – Active • Process in memory – What are they? Only the program code? 19
ProcessinMemorymax· Text sectionstack-Program codeData sectionheap-Global variablesdata· StacktextP- Temporary data (function parameters, return addresseslocal variables)·Heap- Dynamically allocated memory during process run timeProgram counter and contents of registers20
Process in Memory • Text section – Program code • Data section – Global variables • Stack – Temporary data (function parameters, return addresses, local variables) • Heap – Dynamically allocated memory during process run time • Program counter and contents of registers 20