fork() is a UNIX/Linux system call. To my knowledge, it is still not supported in Windows.
The Win32 CreateProcess() function is a Windows function.
Obviously, you will need to write and run the two programs on two different systems. Was that part of your question?
Is the problem that you don't know what fork() does? We really work a lot better when fed specific questions; it keeps us from having to play 20 Questions with you.
Try Google'ing on
man page fork
for more information on that function.
Or, you could read your textbook's explanation.
PS
OK, here's the skinny on fork(). It creates an exact clone of the current process -- except for the process ID (PID) and parent PID (PPID), of course -- starts that clone running starting at the fork() call, and then returns. In both processes. The only way the original process and the clone (AKA "parent and child", respectively) can tell which one they are is from the return value of fork().
So, you assign the return value of fork() to a variable (the parent will need it later) and then test its value in an if-else statement. If the process is the child, then it will do one thing, but if it's the parent, then it will do something different.
Usually, the child will perform whatever special task -- there's an extremely common procedure in UNIX system programming whereby the child replaces itself with an entirely different process, this being the way that one process spawns another, but you don't need to do that here.
And usually the parent will wait for the child to complete its task and terminate, which is what your assignment requires. You'd want to read the man pages for wait() and waitpid(). Your assignment specifically tells you to use wait().
For CreateProcess, you'd want to use Google to find the Microsoft Developer's Network (MSDN) page on that function.
PPS
Could you please explain to us why you've been given an assignment that is specifically for giving you practice in spawning new processes in two different operating systems, and you don't have a single clue about spawning processes? |