final 2024_Remote_Sensing
This commit is contained in:
@@ -1,19 +0,0 @@
|
||||
Node* createNode(int data){
|
||||
|
||||
}
|
||||
|
||||
void insertAtBeginning(LinkedList* head, int data){
|
||||
|
||||
}
|
||||
|
||||
void insertAtEnd(LinkedList* head, int data){
|
||||
|
||||
}
|
||||
|
||||
void deleteNode(LinkedList* head, int key){
|
||||
|
||||
}
|
||||
|
||||
void printList(LinkedList head){
|
||||
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
#ifndef LINKEDLIST_H
|
||||
#define LINKEDLIST_H
|
||||
|
||||
typedef struct node{
|
||||
int data;
|
||||
struct node* next;
|
||||
} Node;
|
||||
|
||||
typedef Node* Linkedlist;
|
||||
|
||||
Node* createNode(int data);
|
||||
|
||||
void insertAtBeginning(LinkedList* head, int data);
|
||||
|
||||
void insertAtEnd(LinkedList* head, int data);
|
||||
|
||||
void deleteNode(LinkedList* head, int key);
|
||||
|
||||
void printList(LinkedList head);
|
||||
|
||||
#endif
|
||||
@@ -1,30 +0,0 @@
|
||||
# Compiler
|
||||
CC = gcc
|
||||
|
||||
# Compiler flags
|
||||
CFLAGS = -Wall -g
|
||||
|
||||
# Target executable
|
||||
TARGET = prog
|
||||
|
||||
# Object files
|
||||
OBJS = stack.o prog.o
|
||||
|
||||
# Default rule to build the target executable
|
||||
all: $(TARGET)
|
||||
|
||||
# Rule to build the target executable from object files
|
||||
$(TARGET): $(OBJS)
|
||||
$(CC) $(CFLAGS) -o $(TARGET) $(OBJS)
|
||||
|
||||
# Rule to compile stack.c to object file
|
||||
stack.o: stack.c stack.h
|
||||
$(CC) $(CFLAGS) -c stack.c
|
||||
|
||||
# Rule to compile prog.c to object file
|
||||
prog.o: prog.c stack.h
|
||||
$(CC) $(CFLAGS) -c prog.c
|
||||
|
||||
# Clean up object files and the executable
|
||||
clean:
|
||||
rm -f $(OBJS) $(TARGET)
|
||||
@@ -1,12 +0,0 @@
|
||||
# Übung 0 Stack
|
||||
|
||||
Dies ist die Vorlage für die Live Aufgabe "Stack".
|
||||
|
||||
Bitte forken Sie diese Vorlage über den Button Fork und wählen Sie ihre Gruppe als URL aus.
|
||||
Anschließend können Sie in Ihrer Version des Projektes arbeiten :)
|
||||
Forderns Sie kein Zugriff auf dieses Projekt an!
|
||||
|
||||
1. Implementieren Sie den Datentyp stack_t.
|
||||
2. Implementieren Sie die auskommentierten Methoden in stack.c.
|
||||
3. Implementieren Sie ein Programm, welches Ihren Stack nutzt in prog.c
|
||||
4. Erstellen Sie ein Makefile, welches die Executable prog erstellt.
|
||||
@@ -1,55 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include "stack.h"
|
||||
|
||||
int main() {
|
||||
|
||||
stack_t* stack = stack_create(5);
|
||||
|
||||
if(stack == NULL){
|
||||
printf("Failed to create stack\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (stack_push(stack, 'A') != 0) {
|
||||
printf("Error: failed to push onto stack\n");
|
||||
stack_delete(stack);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (stack_push(stack, 'B') != 0) {
|
||||
printf("Error: failed to push onto stack\n");
|
||||
stack_delete(stack);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (stack_push(stack, 'C') != 0) {
|
||||
printf("Error: failed to push onto stack\n");
|
||||
stack_delete(stack);
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf("Stack length is %zu\n", stack_length(stack));
|
||||
|
||||
char popped;
|
||||
if (stack_pop(stack, &popped) != 0){
|
||||
printf("Error: failed to pop from stack\n");
|
||||
stack_delete(stack);
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf("Popped element: %c\n", popped);
|
||||
|
||||
if (stack_pop(stack, &popped) != 0){
|
||||
printf("Error: failed to pop from stack\n");
|
||||
stack_delete(stack);
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf("Popped element: %c\n", popped);
|
||||
|
||||
printf("Stack length is %zu\n", stack_length(stack));
|
||||
|
||||
stack_delete(stack);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
#include "stack.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
stack_t *stack_create(size_t size) {
|
||||
stack_t* stack = (stack_t*) malloc(sizeof(stack_t));
|
||||
if (stack == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
stack->array = (char*) malloc(size * sizeof(char));
|
||||
if (stack->array == NULL) {
|
||||
free(stack);
|
||||
return NULL;
|
||||
}
|
||||
stack->size = size;
|
||||
stack->length = 0;
|
||||
return stack;
|
||||
}
|
||||
|
||||
void stack_delete(stack_t *stack) {
|
||||
if (stack != NULL) {
|
||||
free(stack->array);
|
||||
free(stack);
|
||||
}
|
||||
}
|
||||
|
||||
size_t stack_length(stack_t *stack) {
|
||||
return stack->length;
|
||||
}
|
||||
|
||||
int stack_push(stack_t *stack, char c) {
|
||||
if (stack->length >= stack->size) {
|
||||
return -1;
|
||||
}
|
||||
stack->array[stack->length] = c;
|
||||
stack->length++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int stack_pop(stack_t *stack, char *dest) {
|
||||
if (stack->length == 0) {
|
||||
return -1;
|
||||
}
|
||||
*dest = stack->array[stack->length - 1];
|
||||
stack->length--;
|
||||
return 0;
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
#ifndef STACK_H
|
||||
#define STACK_H
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
typedef struct stack{
|
||||
int size;
|
||||
char* array;
|
||||
int length;
|
||||
} stack_t;
|
||||
|
||||
stack_t* stack_create(size_t size);
|
||||
|
||||
void stack_delete(stack_t* stack);
|
||||
|
||||
size_t stack_length(stack_t* stack);
|
||||
|
||||
int stack_push(stack_t* stack,char c);
|
||||
|
||||
int stack_pop(stack_t* stack, char* dest);
|
||||
|
||||
#endif
|
||||
@@ -1,8 +0,0 @@
|
||||
CC = gcc
|
||||
|
||||
all: workdir.c print_file.c
|
||||
${CC} -o workdir workdir.c
|
||||
${CC} -o print_file print_file.c
|
||||
|
||||
clean:
|
||||
rm -f workdir print_file
|
||||
@@ -1,38 +0,0 @@
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define SIZE 512
|
||||
|
||||
int main() {
|
||||
|
||||
int fd = open("./test.txt", O_RDWR);
|
||||
if (fd == -1){
|
||||
perror("could not open file");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
char * buffer = (char *) calloc(SIZE, sizeof(char));
|
||||
|
||||
if (buffer == NULL) {
|
||||
perror("could not allocate buffer");
|
||||
close(fd);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
ssize_t r = read(fd, buffer, SIZE-1);
|
||||
if (r == -1) {
|
||||
perror("could not read file");
|
||||
free(buffer);
|
||||
close(fd);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
return 0;
|
||||
|
||||
printf("%.*s", SIZE-1, buffer);
|
||||
free(buffer);
|
||||
close(fd);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
char *mywdfunc(unsigned int bufsize) {
|
||||
if (bufsize < 100) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char *buf = (char *)calloc(bufsize,sizeof(char));
|
||||
|
||||
if (buf == NULL){
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (getcwd(buf,bufsize-1) == NULL) {
|
||||
free(buf);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
int main() {
|
||||
|
||||
char *ret = mywdfunc(512);
|
||||
|
||||
printf("%s", ret);
|
||||
free(ret);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
# Übung 2 Prozessliste
|
||||
|
||||
Dies ist die Vorlage für die Hausaufgabe "Prozesstabelle".
|
||||
|
||||
Bitte forken Sie diese Vorlage über den Button Fork und wählen Sie ihre Gruppe als URL aus.
|
||||
Anschließend können Sie in Ihrer Version des Projektes arbeiten :)
|
||||
@@ -1,34 +0,0 @@
|
||||
// zum Erstellen der Liste, wobei die Liste zu Beginn einen Prozess mit PID = 1 und PPID = 0 enthalten soll
|
||||
dl_proc_list* dl_proc_list_create() {
|
||||
dl_proc_list* proc_list = (dl_proc_list*) malloc(sizeof(dl_proc_list));
|
||||
if (proc_list == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
proc_list->PID = 1;
|
||||
proc_list->PPID = 0;
|
||||
}
|
||||
|
||||
// zum Einfügen eines Prozesses mit PID pid in die Liste, unter den folgenden Bedingungen:
|
||||
// – Die Liste ist stets aufsteigend sortiert,
|
||||
// – jede Prozess-ID kommt höchstens einmal vor und
|
||||
// – als neuer Elternprozess wird der Prozess mit der bisher höchsten Prozess-ID festgelegt.
|
||||
int dl_proc_list_insert(dl_proc_list *list, int pid){
|
||||
|
||||
}
|
||||
|
||||
// zum Abfragen der PID und PPID des Prozesses an der gegebenen Position in der Liste und Abspeichern der erhaltenen Werte in den Parametern pid und ppid,
|
||||
int dl_proc_list_get(dl_proc_list *list, int position, int* pid, int* ppid){
|
||||
|
||||
}
|
||||
|
||||
// zum Entfernen des Prozesses p mit der PID pid aus der Liste, unter den folgenden Bedingungen:
|
||||
// – Das Löschen des Prozesses mit PID = 1 soll verhindert werden und
|
||||
// – die Kindprozesse des zu löschenden Prozesses p erhalten den Elternprozess von p als neuen Elternprozess.
|
||||
int dl_proc_list_remove(dl_proc_list *list, int pid){
|
||||
|
||||
}
|
||||
|
||||
// zum Freigeben des allokierten Speichers.
|
||||
void dl_proc_list_free(dl_proc_list *list){
|
||||
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
Implementieren Sie eine Prozesstabelle mithilfe einer doppelt verketteten Liste.
|
||||
Die Elemente der Liste entsprechen den vereinfachten Prozessleitblöcken. Für jeden Pro-
|
||||
zess umfasst der zugehörige Leitblock die Prozess-ID (PID) und die ID des Elternprozesses
|
||||
(parent PID, PPID).
|
||||
|
||||
Beachten Sie dabei:
|
||||
• Geben Sie für die Funktionen der doppelt verketteten Liste im Fehlerfall negative
|
||||
Werte und im Erfolgsfall 0 zurück. Falls der Rückgabetyp ein Pointer ist, soll die
|
||||
Funktion im Fehlerfall NULL zurückgeben.
|
||||
|
||||
|
||||
#ifndef dl_proc_list
|
||||
#define dl_proc_list
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
typedef struct dl_proc_list {
|
||||
int PID;
|
||||
int PPID;
|
||||
} dl_proc_list;
|
||||
|
||||
dl_proc_list* dl_proc_list_create()
|
||||
|
||||
int dl_proc_list_insert(dl_proc_list *list, int pid)
|
||||
|
||||
int dl_proc_list_get(dl_proc_list *list, int position, int* pid, int* ppid)
|
||||
|
||||
int dl_proc_list_remove(dl_proc_list *list, int pid)
|
||||
|
||||
void dl_proc_list_free(dl_proc_list *list)
|
||||
|
||||
#endif
|
||||
@@ -1,16 +0,0 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main() {
|
||||
int a[8];
|
||||
int i;
|
||||
|
||||
printf("Size of A: %lu\n", sizeof(a));
|
||||
|
||||
printf("Array A:");
|
||||
|
||||
for (i = 0; i < (sizeof (a)/4); i ++) {
|
||||
a[i] = 1;
|
||||
printf("%i",a[i]);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
#include <stdio.h>
|
||||
|
||||
unsigned long size (int* a){
|
||||
return sizeof (a);
|
||||
}
|
||||
int main (int argc , char ** argv ){
|
||||
int a[8];
|
||||
printf ("%lu",size (a));
|
||||
}
|
||||
Submodule 2024_Grundlagen_Betriebssysteme_Rechnernetze/uebung-3-pthreads deleted from 61606e3117
Reference in New Issue
Block a user