Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lisa Cee #1

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,18 @@ type `make` in the `examples/` directory.) It should print `Testing: PASS`.
Add your answers inline, below, with your pull request.

1. List all of the main states a process may be in at any point in time on a standard Unix system. Briefly explain what each of these states means.
*Running - A process is in the state of running when it is actively being processed by the computer.
*Suspended - A process is suspended when it is minimized and a different process is being worked on.
*Blocked - A process is blocked when it is waiting for input from a user or another process before it can continue to running.
*Dead - A dead process has been closed/completed
*Sleeping - A sleeping process is still open, but that doesn't need to be processed right now.
*Stopped - A stopped process is no longer running.

2. What is a zombie process? How does one get created? How does one get destroyed?
A zombie is a child process that has completed (dead), but it still exists in the process table. A zombie process can be prevented by using a wait() or exit() call in the original function (parent). You can destroy a zombie process by killing the parent process or restarting the computer.

3. What are some of the benefits of working in a compiled language versus a non-compiled language? More specifically, what benefits are there to be had from taking the extra time to compile our code?

Compiled languages can be compiled once and then run multiple times without having to recompile (unless there are changes to the code). This makes compiled languages much more efficient than non-compiled languages which interprets the code as it runs. Compiled languages also check for errors before it runs, allowing it to be corrected before the code is executed.

## Task 2

Expand Down
Binary file added lsls/lsls
Binary file not shown.
33 changes: 26 additions & 7 deletions lsls/lsls.c
Original file line number Diff line number Diff line change
@@ -1,18 +1,37 @@
#include <stdio.h>
#include <dirent.h>
#include <stdlib.h>
#include <sys/stat.h>

/**
/**
* Main
*/
int main(int argc, char **argv)
int main(int argc, char *argv)
{
// Parse command line
DIR *d;
struct dirent *dir;
struct stat buf;
printf("Enter a directory: \n");
scanf("%s", argv);
d = opendir(argv);

// Open directory
if( !d ) {
d = opendir(".");
}

// Repeatly read and print entries
if (d == NULL) {
printf("There was an error opening this directory");
exit(0);
}

// Close directory
while ((dir = readdir(d)) != NULL)
{
stat(dir->d_name, &buf);
printf("%10ld ", buf.st_size);
printf("%s\n", dir->d_name);
}
closedir(d);

return 0;
}

}