Git Product home page Git Product logo

os-socket-thread's Introduction

HW2 Simple Key-value Store

Directories

  • /server -> server program related sources
  • /client -> client program related sources
  • /common -> common inclusions
  • /util -> common utilization
  • /build -> target build directory

Building the Project

Code out your /server/server.c and /client/client.c, then

$ make

Test your /build/server and build/client.

Implementations

Please briefly describe your multi-threading design pattern

  1. Use pthread_t threads[10] array and bool *thread_sum array to record the pthread
  2. Once server accept the client, the server use pthread_create to carry out the multi-thread.
  3. If Clients are up to 10, the server will not accept new client.
  4. Use pthread_mutex_lock and pthread_mutex_unlock to avoid race condition.

Please briefly describe your data structure implementation

DataNode

typedef struct HashNode
{
    struct HashNode* next;
    char *key;
    char *value;
} HashNode;
  1. Use Hash Table as the DataBase. a linked list array (size = 26)
  2. int Hashing (char* Key); : Use Key to create Hash value (0-25)
  3. HashNode* HashNode_Create(char *Key, char *Value); Create a Link-list Node
  4. HashNode* HashNode_Insert(HashNode* Root, char* Key,char* Value); : Save K-V pair to Hash Table (as a linked list).
  5. HashNode* HashNode_Search(HashNode* Root,char *Key); : Search the Key and Return Value.
  6. HashNode* HashNode_Delete(HashNode* Root,char *Key); : Delete the K-V pair.

References

os-socket-thread's People

Contributors

ypctw avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.